From cfe9ed31e62c20336f64afc30b0d5bc4150e1877 Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Tue, 14 Dec 2021 22:38:04 +0800 Subject: [PATCH 1/9] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cweb/controller/HighTestController.java | 2 +- .../controller/pay/UnionPayController.java | 19 +++++++++++ .../com/hai/config/UnionStagingPayConfig.java | 33 +++++++++++++++---- .../resources/dev/commonConfig.properties | 2 +- .../resources/pre/commonConfig.properties | 7 ++++ .../prod-9401/commonConfig.properties | 7 ++++ .../resources/prod/commonConfig.properties | 7 ++++ 7 files changed, 69 insertions(+), 8 deletions(-) diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighTestController.java b/hai-cweb/src/main/java/com/cweb/controller/HighTestController.java index 8fd08541..c7540392 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighTestController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighTestController.java @@ -1 +1 @@ -package com.cweb.controller; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.cweb.config.SysConst; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.pay.util.XmlUtil; import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.utils.*; import com.hai.config.*; import com.hai.dao.HighGasOrderPushMapper; import com.hai.entity.*; import com.hai.model.*; import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.ssl.SSLContexts; import org.apache.http.util.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Controller; import org.springframework.util.IdGenerator; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.net.ssl.SSLContext; import java.io.FileInputStream; import java.math.BigDecimal; import java.security.KeyStore; import java.util.*; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/test") @Api(value = "订单接口") public class HighTestController { private static Logger log = LoggerFactory.getLogger(HighTestController.class); @Resource private HighMerchantService highMerchantService; @Resource private HighMerchantStoreService highMerchantStoreService; @Resource private HighGasOilPriceService highGasOilPriceService; @Resource private HighOrderService highOrderService; @Resource private HighProfitSharingRecordService highProfitSharingRecordService; @Resource private HighGasOrderPushMapper highGasOrderPushMapper; @Resource private HuiLianTongConfig huiLianTongConfig; @Resource private UnionPayConfig unionPayConfig; @Resource private UnionUserConfig unionUserConfig; @RequestMapping(value = "/initTYMerchantStore", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "初始化加油站") public ResponseData initTYMerchantStore(@RequestParam(name = "merchantId", required = true) Long merchantId) throws Exception { HighMerchantModel merchant = highMerchantService.getMerchantById(merchantId); if (merchant == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到商户"); } JSONObject jsonObjectP = TuanYouConfig.queryGasInfoListByPage(1, 1000); JSONObject resultObjectP = jsonObjectP.getObject("result", JSONObject.class); for (int i = 1; i <= resultObjectP.getInteger("totalPageNum").intValue();i++) { JSONObject jsonObject = TuanYouConfig.queryGasInfoListByPage(i, 1000); JSONObject resultObject = jsonObject.getObject("result", JSONObject.class); JSONArray jsonArray = resultObject.getJSONArray("gasInfoList"); HighMerchantStore highMerchantStore; HighGasOilPrice highGasOilPrice; for (Object gasObject : jsonArray) { JSONObject object = JSONObject.parseObject(JSONObject.toJSONString(gasObject)); HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreByKey(object.getString("gasId")); if (store != null) { store.setType(1); store.setMerchantId(merchant.getId()); store.setCompanyId(merchant.getCompanyId()); store.setStoreKey(object.getString("gasId")); store.setStoreName(object.getString("gasName")); store.setStoreLogo(object.getString("gasLogoSmall")); store.setRegionId(object.getLong("provinceCode")); store.setRegionName(object.getString("provinceName")); store.setAddress(object.getString("gasAddress")); store.setLongitude(object.getString("gasAddressLongitude")); store.setLatitude(object.getString("gasAddressLatitude")); store.setStatus(object.getInteger("gasStatus")); store.setOperatorId(0L); store.setOperatorName("系统创建"); store.setUpdateTime(new Date()); store.setExt1(object.getString("gasSourceId")); highMerchantStoreService.updateMerchantStoreDetail(store); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); // 查询门店油号 highGasOilPrice = highGasOilPriceService.getGasOilPriceByStoreAndOilNo(store.getId(), oilPriceObject.getInteger("oilNo")); if (highGasOilPrice == null) { highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); } else { highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); } highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } else { highMerchantStore = new HighMerchantStore(); highMerchantStore.setType(1); highMerchantStore.setMerchantId(merchant.getId()); highMerchantStore.setCompanyId(merchant.getCompanyId()); highMerchantStore.setStoreKey(object.getString("gasId")); highMerchantStore.setStoreName(object.getString("gasName")); highMerchantStore.setStoreLogo(object.getString("gasLogoSmall")); highMerchantStore.setRegionId(object.getLong("provinceCode")); highMerchantStore.setRegionName(object.getString("provinceName")); highMerchantStore.setAddress(object.getString("gasAddress")); highMerchantStore.setLongitude(object.getString("gasAddressLongitude")); highMerchantStore.setLatitude(object.getString("gasAddressLatitude")); highMerchantStore.setStatus(1); highMerchantStore.setOperatorId(0L); highMerchantStore.setOperatorName("系统创建"); highMerchantStore.setCreateTime(new Date()); highMerchantStore.setUpdateTime(new Date()); highMerchantStore.setExt1(object.getString("gasSourceId")); HighMerchantStoreModel merchantStoreModel = new HighMerchantStoreModel(); BeanUtils.copyProperties(highMerchantStore, merchantStoreModel); highMerchantStoreService.insertMerchantStore(merchantStoreModel); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(merchantStoreModel.getId()); highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } } } return ResponseMsgUtil.success("初始化完成"); } @RequestMapping(value = "/pushTuanYouOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "推送团油订单") public ResponseData pushTuanYouOrder() { try { HighOrder order = highOrderService.getOrderByOrderNo("HF2021102112141171406"); for (HighChildOrder highChildOrder : order.getHighChildOrderList()) { HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreById(highChildOrder.getGoodsId()); // 推送团油订单 Map paramMap = new HashMap<>(); paramMap.put("gasId", store.getStoreKey()); paramMap.put("oilNo", highChildOrder.getGasOilNo()); paramMap.put("gunNo", highChildOrder.getGasGunNo()); BigDecimal priceGun = highChildOrder.getGasPriceGun(); BigDecimal priceVip = highChildOrder.getGasPriceVip(); paramMap.put("priceGun", priceGun); // 枪单价 paramMap.put("priceVip", priceVip); // 优惠价 paramMap.put("driverPhone", order.getMemPhone()); // paramMap.put("driverPhone", "17726395120"); paramMap.put("thirdSerialNo", order.getOrderNo()); paramMap.put("refuelingAmount", highChildOrder.getTotalPrice()); // 油品类型 1:汽油:2:柴油;3:天然气 if (highChildOrder.getGasOilType() == 1) { paramMap.put("accountNo", CommonSysConst.getSysConfig().getTuanYouGasolineAccount()); } else if (highChildOrder.getGasOilType() == 2) { paramMap.put("accountNo", CommonSysConst.getSysConfig().getTuanYouDieselAccount()); } JSONObject orderPushObject = TuanYouConfig.refuelingOrderPush(paramMap); // 推送团油订单记录 HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); highGasOrderPush.setCreateTime(new Date()); highGasOrderPush.setCode(orderPushObject.getString("code")); highGasOrderPush.setRequestContent(JSONObject.toJSONString(paramMap)); highGasOrderPush.setReturnContent(orderPushObject.toJSONString()); highGasOrderPushMapper.insert(highGasOrderPush); if (orderPushObject != null && orderPushObject.getString("code").equals("200")) { highChildOrder.setGasOrderNo(orderPushObject.getJSONObject("result").getString("orderNo")); } highOrderService.updateOrder(order); } return ResponseMsgUtil.success(order); } catch (Exception e) { log.error("HighOrderController --> getOrderById() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryCompanyAccountInfo2JD", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询团油余额") public ResponseData queryCompanyAccountInfo2JD() { try { return ResponseMsgUtil.success(TuanYouConfig.queryCompanyAccountInfo2JD()); } catch (Exception e) { log.error("HighOrderController --> queryCompanyAccountInfo2JD() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/couJointDist", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "派发贵州卡券") public ResponseData couJointDist(@RequestParam(name = "token", required = true) String token) { try { return ResponseMsgUtil.success(HuiLianTongConfig.couJointDist(token,"HF"+System.currentTimeMillis(),"20JY000251",2,"17726395120", "oArhO6XxKSvjI9wLP3cTK-iSG8yY")); } catch (Exception e) { log.error("HighOrderController --> getOrderById() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/unionPay", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "银联支付") public ResponseData unionPay() { try { return ResponseMsgUtil.success(unionPayConfig.upPreOrder("HF"+System.currentTimeMillis(), new BigDecimal("1"), "test",CommonSysConst.getSysConfig().getUnionPayNotifyUrl())); } catch (Exception e) { log.error("HighOrderController --> getOrderById() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getToken", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取贵州中石化token") public ResponseData getToken() { try { return ResponseMsgUtil.success(huiLianTongConfig.getToken()); } catch (Exception e) { log.error("HighOrderController --> getToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/unionTradeQuery", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "银联交易查询") public ResponseData unionTradeQuery(@RequestParam(name = "paySerialNo", required = true) String paySerialNo) { try { return ResponseMsgUtil.success(UnionPayConfig.tradeQuery(paySerialNo)); } catch (Exception e) { log.error("HighOrderController --> unionTradeQuery() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getBackendToken", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取访问令牌backendToken") public ResponseData getBackendToken() { try { return ResponseMsgUtil.success(unionUserConfig.getBackendToken()); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/wxSplitAccount", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "微信分账") public ResponseData wxSplitAccount() { try { HighOrder orderNo = highOrderService.getOrderByOrderNo("HF2021101812025050304"); wxProfitsharing(orderNo.getOrderNo(),orderNo.getPaySerialNo(),orderNo.getPayRealPrice()); return ResponseMsgUtil.success("分账成功"); } catch (Exception e) { log.error("HighOrderController --> getOrderById() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/unionStagingPay", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "银联分期支付") public ResponseData unionStagingPay() { try { String orderNo = DateUtil.format(new Date(), DateUtil.YMDHMS); orderNo += IDGenerator.nextId(28 - orderNo.length()); String orgTrace = CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(0,4) +CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length() - 4,CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length()) +DateUtil.format(new Date(), DateUtil.YMDHMS) +IDGenerator.nextId(6); return ResponseMsgUtil.success(UnionStagingPayConfig.advancePay( orderNo, orgTrace, new BigDecimal("1"), "-", CommonSysConst.getSysConfig().getUnionStagingPayNotifyUrl())); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } public void wxProfitsharing(String transaction_id,String out_order_no, BigDecimal amount) { try { Map param = new LinkedHashMap<>(); param.put("appid", "wx637bd6f7314daa46"); param.put("mch_id", "1289663601"); param.put("sub_mch_id" , "1609882817"); // 个体户黎杨珍 param.put("transaction_id" , transaction_id); param.put("out_order_no" , out_order_no); param.put("nonce_str" , WxUtils.makeNonStr()); // 分账金额 BigDecimal porofitSharingAmount = amount; List> receiversList = new ArrayList<>(); Map receiversMap = new LinkedHashMap<>(); receiversMap.put("type", "MERCHANT_ID"); receiversMap.put("account", "1603942866"); receiversMap.put("amount", porofitSharingAmount.multiply(new BigDecimal("100")).intValue()); receiversMap.put("description", "分给商户【惠昕石化】"); receiversList.add(receiversMap); param.put("receivers" , JSONObject.toJSONString(receiversList)); String signStr = WxUtils.generateSignature(param, "Skufk5oi85wDFGl888i6wsRSTkdd5df5" , WXPayConstants.SignType.HMACSHA256); param.put("sign" , signStr); String resultXmL = this.doRefundRequest(param.get("mch_id"),null, WxUtils.mapToXml(param)); // 请求分账返回的结果 ResultProfitSharing resultProfitSharing = XmlUtil.getObjectFromXML(resultXmL, ResultProfitSharing.class); if (!resultProfitSharing.getResult_code().equals("FAIL")) { HighProfitSharingRecord sharingRecord = new HighProfitSharingRecord(); sharingRecord.setOutOrderNo(resultProfitSharing.getOut_order_no()); sharingRecord.setTransactionId(resultProfitSharing.getTransaction_id()); sharingRecord.setOrderId(resultProfitSharing.getOrder_id()); sharingRecord.setStatus(resultProfitSharing.getResult_code()); sharingRecord.setPrice(amount); sharingRecord.setCreateTime(new Date()); sharingRecord.setContent(resultXmL); highProfitSharingRecordService.insert(sharingRecord); } } catch (Exception e) { log.error("CmsContentController --> getCorporateAdvertising() error!", e); } } public CloseableHttpClient readCertificate(String mchId) throws Exception{ /** * 注意PKCS12证书 是从微信商户平台-》账户设置-》 API安全 中下载的 */ KeyStore keyStore = KeyStore.getInstance("PKCS12"); //P12文件目录 证书路径,这里需要你自己修改,linux下还是windows下的根路径 FileInputStream instream = new FileInputStream("/home/project/wx_cert/1289663601_apiclient_cert.p12"); // FileInputStream instream = new FileInputStream("G:\\hurui-project/hai-parent/hai-service/src/main/java/privatekey/1289663601_apiclient_cert.p12"); try { keyStore.load(instream, "1289663601".toCharArray());//这里写密码..默认是你的MCHID } finally { instream.close(); } SSLContext sslcontext = SSLContexts.custom().loadKeyMaterial(keyStore, "1289663601".toCharArray()).build();//这里也是写密码的 SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslcontext, SSLConnectionSocketFactory.getDefaultHostnameVerifier()); // Allow TLSv1 protocol only return HttpClients.custom().setSSLSocketFactory(sslsf).build(); } public String doRefundRequest(String mchId, String url, String data) throws Exception { //小程序退款需要调用双向证书的认证 CloseableHttpClient httpClient = readCertificate(mchId); try { HttpPost httpost = new HttpPost("https://api.mch.weixin.qq.com/secapi/pay/refund"); // 设置响应头信息 httpost.addHeader("Connection", "keep-alive"); httpost.addHeader("Accept", "*/*"); httpost.addHeader("Content-Type", "text/xml"); httpost.addHeader("Host", "api.mch.weixin.qq.com"); httpost.addHeader("X-Requested-With", "XMLHttpRequest"); httpost.addHeader("Cache-Control", "max-age=0"); httpost.addHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0) "); httpost.setEntity(new StringEntity(data, "UTF-8")); CloseableHttpResponse response = httpClient.execute(httpost); try { HttpEntity entity = response.getEntity(); String jsonStr = EntityUtils.toString(response.getEntity(), "UTF-8"); EntityUtils.consume(entity); return jsonStr; } finally { response.close(); } } catch (Exception e){ throw new RuntimeException(e); } finally { httpClient.close(); } } } \ No newline at end of file +package com.cweb.controller; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.cweb.config.SysConst; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.pay.util.XmlUtil; import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.utils.*; import com.hai.config.*; import com.hai.dao.HighGasOrderPushMapper; import com.hai.entity.*; import com.hai.model.*; import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.ssl.SSLContexts; import org.apache.http.util.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Controller; import org.springframework.util.IdGenerator; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.net.ssl.SSLContext; import java.io.FileInputStream; import java.math.BigDecimal; import java.security.KeyStore; import java.util.*; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/test") @Api(value = "订单接口") public class HighTestController { private static Logger log = LoggerFactory.getLogger(HighTestController.class); @Resource private HighMerchantService highMerchantService; @Resource private HighMerchantStoreService highMerchantStoreService; @Resource private HighGasOilPriceService highGasOilPriceService; @Resource private HighOrderService highOrderService; @Resource private HighProfitSharingRecordService highProfitSharingRecordService; @Resource private HighGasOrderPushMapper highGasOrderPushMapper; @Resource private HuiLianTongConfig huiLianTongConfig; @Resource private UnionPayConfig unionPayConfig; @Resource private UnionUserConfig unionUserConfig; @RequestMapping(value = "/initTYMerchantStore", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "初始化加油站") public ResponseData initTYMerchantStore(@RequestParam(name = "merchantId", required = true) Long merchantId) throws Exception { HighMerchantModel merchant = highMerchantService.getMerchantById(merchantId); if (merchant == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到商户"); } JSONObject jsonObjectP = TuanYouConfig.queryGasInfoListByPage(1, 1000); JSONObject resultObjectP = jsonObjectP.getObject("result", JSONObject.class); for (int i = 1; i <= resultObjectP.getInteger("totalPageNum").intValue();i++) { JSONObject jsonObject = TuanYouConfig.queryGasInfoListByPage(i, 1000); JSONObject resultObject = jsonObject.getObject("result", JSONObject.class); JSONArray jsonArray = resultObject.getJSONArray("gasInfoList"); HighMerchantStore highMerchantStore; HighGasOilPrice highGasOilPrice; for (Object gasObject : jsonArray) { JSONObject object = JSONObject.parseObject(JSONObject.toJSONString(gasObject)); HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreByKey(object.getString("gasId")); if (store != null) { store.setType(1); store.setMerchantId(merchant.getId()); store.setCompanyId(merchant.getCompanyId()); store.setStoreKey(object.getString("gasId")); store.setStoreName(object.getString("gasName")); store.setStoreLogo(object.getString("gasLogoSmall")); store.setRegionId(object.getLong("provinceCode")); store.setRegionName(object.getString("provinceName")); store.setAddress(object.getString("gasAddress")); store.setLongitude(object.getString("gasAddressLongitude")); store.setLatitude(object.getString("gasAddressLatitude")); store.setStatus(object.getInteger("gasStatus")); store.setOperatorId(0L); store.setOperatorName("系统创建"); store.setUpdateTime(new Date()); store.setExt1(object.getString("gasSourceId")); highMerchantStoreService.updateMerchantStoreDetail(store); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); // 查询门店油号 highGasOilPrice = highGasOilPriceService.getGasOilPriceByStoreAndOilNo(store.getId(), oilPriceObject.getInteger("oilNo")); if (highGasOilPrice == null) { highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); } else { highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); } highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } else { highMerchantStore = new HighMerchantStore(); highMerchantStore.setType(1); highMerchantStore.setMerchantId(merchant.getId()); highMerchantStore.setCompanyId(merchant.getCompanyId()); highMerchantStore.setStoreKey(object.getString("gasId")); highMerchantStore.setStoreName(object.getString("gasName")); highMerchantStore.setStoreLogo(object.getString("gasLogoSmall")); highMerchantStore.setRegionId(object.getLong("provinceCode")); highMerchantStore.setRegionName(object.getString("provinceName")); highMerchantStore.setAddress(object.getString("gasAddress")); highMerchantStore.setLongitude(object.getString("gasAddressLongitude")); highMerchantStore.setLatitude(object.getString("gasAddressLatitude")); highMerchantStore.setStatus(1); highMerchantStore.setOperatorId(0L); highMerchantStore.setOperatorName("系统创建"); highMerchantStore.setCreateTime(new Date()); highMerchantStore.setUpdateTime(new Date()); highMerchantStore.setExt1(object.getString("gasSourceId")); HighMerchantStoreModel merchantStoreModel = new HighMerchantStoreModel(); BeanUtils.copyProperties(highMerchantStore, merchantStoreModel); highMerchantStoreService.insertMerchantStore(merchantStoreModel); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(merchantStoreModel.getId()); highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } } } return ResponseMsgUtil.success("初始化完成"); } @RequestMapping(value = "/pushTuanYouOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "推送团油订单") public ResponseData pushTuanYouOrder() { try { HighOrder order = highOrderService.getOrderByOrderNo("HF2021102112141171406"); for (HighChildOrder highChildOrder : order.getHighChildOrderList()) { HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreById(highChildOrder.getGoodsId()); // 推送团油订单 Map paramMap = new HashMap<>(); paramMap.put("gasId", store.getStoreKey()); paramMap.put("oilNo", highChildOrder.getGasOilNo()); paramMap.put("gunNo", highChildOrder.getGasGunNo()); BigDecimal priceGun = highChildOrder.getGasPriceGun(); BigDecimal priceVip = highChildOrder.getGasPriceVip(); paramMap.put("priceGun", priceGun); // 枪单价 paramMap.put("priceVip", priceVip); // 优惠价 paramMap.put("driverPhone", order.getMemPhone()); // paramMap.put("driverPhone", "17726395120"); paramMap.put("thirdSerialNo", order.getOrderNo()); paramMap.put("refuelingAmount", highChildOrder.getTotalPrice()); // 油品类型 1:汽油:2:柴油;3:天然气 if (highChildOrder.getGasOilType() == 1) { paramMap.put("accountNo", CommonSysConst.getSysConfig().getTuanYouGasolineAccount()); } else if (highChildOrder.getGasOilType() == 2) { paramMap.put("accountNo", CommonSysConst.getSysConfig().getTuanYouDieselAccount()); } JSONObject orderPushObject = TuanYouConfig.refuelingOrderPush(paramMap); // 推送团油订单记录 HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); highGasOrderPush.setCreateTime(new Date()); highGasOrderPush.setCode(orderPushObject.getString("code")); highGasOrderPush.setRequestContent(JSONObject.toJSONString(paramMap)); highGasOrderPush.setReturnContent(orderPushObject.toJSONString()); highGasOrderPushMapper.insert(highGasOrderPush); if (orderPushObject != null && orderPushObject.getString("code").equals("200")) { highChildOrder.setGasOrderNo(orderPushObject.getJSONObject("result").getString("orderNo")); } highOrderService.updateOrder(order); } return ResponseMsgUtil.success(order); } catch (Exception e) { log.error("HighOrderController --> getOrderById() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryCompanyAccountInfo2JD", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询团油余额") public ResponseData queryCompanyAccountInfo2JD() { try { return ResponseMsgUtil.success(TuanYouConfig.queryCompanyAccountInfo2JD()); } catch (Exception e) { log.error("HighOrderController --> queryCompanyAccountInfo2JD() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/couJointDist", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "派发贵州卡券") public ResponseData couJointDist(@RequestParam(name = "token", required = true) String token) { try { return ResponseMsgUtil.success(HuiLianTongConfig.couJointDist(token,"HF"+System.currentTimeMillis(),"20JY000251",2,"17726395120", "oArhO6XxKSvjI9wLP3cTK-iSG8yY")); } catch (Exception e) { log.error("HighOrderController --> getOrderById() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/unionPay", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "银联支付") public ResponseData unionPay() { try { return ResponseMsgUtil.success(unionPayConfig.upPreOrder("HF"+System.currentTimeMillis(), new BigDecimal("1"), "test",CommonSysConst.getSysConfig().getUnionPayNotifyUrl())); } catch (Exception e) { log.error("HighOrderController --> getOrderById() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getToken", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取贵州中石化token") public ResponseData getToken() { try { return ResponseMsgUtil.success(huiLianTongConfig.getToken()); } catch (Exception e) { log.error("HighOrderController --> getToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/unionTradeQuery", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "银联交易查询") public ResponseData unionTradeQuery(@RequestParam(name = "paySerialNo", required = true) String paySerialNo) { try { return ResponseMsgUtil.success(UnionPayConfig.tradeQuery(paySerialNo)); } catch (Exception e) { log.error("HighOrderController --> unionTradeQuery() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getBackendToken", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取访问令牌backendToken") public ResponseData getBackendToken() { try { return ResponseMsgUtil.success(unionUserConfig.getBackendToken()); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/wxSplitAccount", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "微信分账") public ResponseData wxSplitAccount() { try { HighOrder orderNo = highOrderService.getOrderByOrderNo("HF2021101812025050304"); wxProfitsharing(orderNo.getOrderNo(),orderNo.getPaySerialNo(),orderNo.getPayRealPrice()); return ResponseMsgUtil.success("分账成功"); } catch (Exception e) { log.error("HighOrderController --> getOrderById() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/unionStagingPay", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "银联分期支付") public ResponseData unionStagingPay() { try { /* String orderNo = DateUtil.format(new Date(), DateUtil.YMDHMS); orderNo += IDGenerator.nextId(28 - orderNo.length());*/ String orgTrace = CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(0,4) +CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length() - 4,CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length()) +DateUtil.format(new Date(), DateUtil.YMDHMS) +IDGenerator.nextId(6); return ResponseMsgUtil.success(UnionStagingPayConfig.advancePay( orgTrace, orgTrace, new BigDecimal("1"), "62285", "c8BHfKVs6l68BBP9KD9jz4QLJCd/IKW/D+EsM0BLKzb/E7l8k4+aO/Y/h5j89s1X", CommonSysConst.getSysConfig().getUnionStagingPayNotifyUrl())); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryStaging", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "银联分期支付") public ResponseData queryStaging(@RequestParam(name = "orgTrace", required = true) String orgTrace) { try { return ResponseMsgUtil.success(UnionStagingPayConfig.queryStaging(orgTrace, "", new Date())); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } public void wxProfitsharing(String transaction_id,String out_order_no, BigDecimal amount) { try { Map param = new LinkedHashMap<>(); param.put("appid", "wx637bd6f7314daa46"); param.put("mch_id", "1289663601"); param.put("sub_mch_id" , "1609882817"); // 个体户黎杨珍 param.put("transaction_id" , transaction_id); param.put("out_order_no" , out_order_no); param.put("nonce_str" , WxUtils.makeNonStr()); // 分账金额 BigDecimal porofitSharingAmount = amount; List> receiversList = new ArrayList<>(); Map receiversMap = new LinkedHashMap<>(); receiversMap.put("type", "MERCHANT_ID"); receiversMap.put("account", "1603942866"); receiversMap.put("amount", porofitSharingAmount.multiply(new BigDecimal("100")).intValue()); receiversMap.put("description", "分给商户【惠昕石化】"); receiversList.add(receiversMap); param.put("receivers" , JSONObject.toJSONString(receiversList)); String signStr = WxUtils.generateSignature(param, "Skufk5oi85wDFGl888i6wsRSTkdd5df5" , WXPayConstants.SignType.HMACSHA256); param.put("sign" , signStr); String resultXmL = this.doRefundRequest(param.get("mch_id"),null, WxUtils.mapToXml(param)); // 请求分账返回的结果 ResultProfitSharing resultProfitSharing = XmlUtil.getObjectFromXML(resultXmL, ResultProfitSharing.class); if (!resultProfitSharing.getResult_code().equals("FAIL")) { HighProfitSharingRecord sharingRecord = new HighProfitSharingRecord(); sharingRecord.setOutOrderNo(resultProfitSharing.getOut_order_no()); sharingRecord.setTransactionId(resultProfitSharing.getTransaction_id()); sharingRecord.setOrderId(resultProfitSharing.getOrder_id()); sharingRecord.setStatus(resultProfitSharing.getResult_code()); sharingRecord.setPrice(amount); sharingRecord.setCreateTime(new Date()); sharingRecord.setContent(resultXmL); highProfitSharingRecordService.insert(sharingRecord); } } catch (Exception e) { log.error("CmsContentController --> getCorporateAdvertising() error!", e); } } public CloseableHttpClient readCertificate(String mchId) throws Exception{ /** * 注意PKCS12证书 是从微信商户平台-》账户设置-》 API安全 中下载的 */ KeyStore keyStore = KeyStore.getInstance("PKCS12"); //P12文件目录 证书路径,这里需要你自己修改,linux下还是windows下的根路径 FileInputStream instream = new FileInputStream("/home/project/wx_cert/1289663601_apiclient_cert.p12"); // FileInputStream instream = new FileInputStream("G:\\hurui-project/hai-parent/hai-service/src/main/java/privatekey/1289663601_apiclient_cert.p12"); try { keyStore.load(instream, "1289663601".toCharArray());//这里写密码..默认是你的MCHID } finally { instream.close(); } SSLContext sslcontext = SSLContexts.custom().loadKeyMaterial(keyStore, "1289663601".toCharArray()).build();//这里也是写密码的 SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslcontext, SSLConnectionSocketFactory.getDefaultHostnameVerifier()); // Allow TLSv1 protocol only return HttpClients.custom().setSSLSocketFactory(sslsf).build(); } public String doRefundRequest(String mchId, String url, String data) throws Exception { //小程序退款需要调用双向证书的认证 CloseableHttpClient httpClient = readCertificate(mchId); try { HttpPost httpost = new HttpPost("https://api.mch.weixin.qq.com/secapi/pay/refund"); // 设置响应头信息 httpost.addHeader("Connection", "keep-alive"); httpost.addHeader("Accept", "*/*"); httpost.addHeader("Content-Type", "text/xml"); httpost.addHeader("Host", "api.mch.weixin.qq.com"); httpost.addHeader("X-Requested-With", "XMLHttpRequest"); httpost.addHeader("Cache-Control", "max-age=0"); httpost.addHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0) "); httpost.setEntity(new StringEntity(data, "UTF-8")); CloseableHttpResponse response = httpClient.execute(httpost); try { HttpEntity entity = response.getEntity(); String jsonStr = EntityUtils.toString(response.getEntity(), "UTF-8"); EntityUtils.consume(entity); return jsonStr; } finally { response.close(); } } catch (Exception e){ throw new RuntimeException(e); } finally { httpClient.close(); } } } \ No newline at end of file diff --git a/hai-cweb/src/main/java/com/cweb/controller/pay/UnionPayController.java b/hai-cweb/src/main/java/com/cweb/controller/pay/UnionPayController.java index ffb1f4a8..3322ed8e 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/pay/UnionPayController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/pay/UnionPayController.java @@ -404,4 +404,23 @@ public class UnionPayController { } } + @RequestMapping(value = "/stagingNotify", method = RequestMethod.POST) + @ApiOperation(value = "银联分期支付 -> 异步回调") + public void stagingNotify(@RequestBody String params,HttpServletRequest request, HttpServletResponse response) { + try { + + System.out.println(params); + log.info(params); + + BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream()); + JSONObject result = new JSONObject(); + result.put("tradeRetCode", "000000"); + out.write(result.toJSONString().getBytes()); + out.flush(); + out.close(); + } catch (Exception e) { + log.error("UnionPayController --> stagingNotify() error!", e); + } + } + } diff --git a/hai-service/src/main/java/com/hai/config/UnionStagingPayConfig.java b/hai-service/src/main/java/com/hai/config/UnionStagingPayConfig.java index f574582f..af26ce53 100644 --- a/hai-service/src/main/java/com/hai/config/UnionStagingPayConfig.java +++ b/hai-service/src/main/java/com/hai/config/UnionStagingPayConfig.java @@ -1,6 +1,7 @@ package com.hai.config; import com.alibaba.fastjson.JSONObject; +import com.hai.common.utils.DateUtil; import com.wechat.pay.contrib.apache.httpclient.util.PemUtil; import org.apache.commons.codec.binary.Base64; import com.hai.common.pay.util.sdk.WXPayConstants; @@ -24,15 +25,16 @@ public class UnionStagingPayConfig { /** * 银联分期支付,H5预下单-标准 - * 文档地址: https://doc.eycard.cn/web/#/42?page_id=1516 + * 文档地址: https://doc.eycard.cn/web/#/222?page_id=3183 * @param orderNo 订单号 * @param orgTrace 订单号 + * @param appId 支付宝、微信、云闪付商户应用ID(一般情况下与获取’openId’时的应用一致) * @param openId 支付宝、微信、云闪付用户授权唯一标识(如果没有,送:-) * @param payPrice 支付金额 【单位:分】 * @return 响应信息 * @throws Exception */ - public static JSONObject advancePay(String orderNo, String orgTrace, BigDecimal payPrice, String openId, String notifyUrl) throws Exception { + public static JSONObject advancePay(String orderNo, String orgTrace, BigDecimal payPrice, String appId,String openId, String notifyUrl) throws Exception { Map paramMap = new HashMap<>(); paramMap.put("orgId", CommonSysConst.getSysConfig().getUnionStagingPayOrgId()); paramMap.put("orgMerCode", CommonSysConst.getSysConfig().getUnionStagingPayOrgMerCode()); @@ -44,6 +46,7 @@ public class UnionStagingPayConfig { Map bizDataMap = new HashMap<>(); bizDataMap.put("transAmt", payPrice.multiply(new BigDecimal("100")).intValue()); + bizDataMap.put("appId", appId); bizDataMap.put("openId", openId); bizDataMap.put("notifyUrl", notifyUrl); paramMap.put("bizData", bizDataMap); @@ -53,7 +56,7 @@ public class UnionStagingPayConfig { return responseParam; } - public static JSONObject query(String orderNo, String orgTrace, BigDecimal payPrice, String openId, String notifyUrl) throws Exception { + public static JSONObject query(String orgTrace, String prodCode) throws Exception { Map paramMap = new HashMap<>(); paramMap.put("orgId", CommonSysConst.getSysConfig().getUnionStagingPayOrgId()); paramMap.put("orgMerCode", CommonSysConst.getSysConfig().getUnionStagingPayOrgMerCode()); @@ -63,9 +66,8 @@ public class UnionStagingPayConfig { paramMap.put("signType", "RSA"); Map bizDataMap = new HashMap<>(); - bizDataMap.put("transAmt", payPrice.multiply(new BigDecimal("100")).intValue()); - bizDataMap.put("openId", openId); - bizDataMap.put("notifyUrl", notifyUrl); + bizDataMap.put("oriOrgTrace", null); + bizDataMap.put("oriBizDate", null); paramMap.put("bizData", bizDataMap); paramMap.put("sign", generateSign(bizDataMap)); @@ -73,6 +75,25 @@ public class UnionStagingPayConfig { return responseParam; } + public static JSONObject queryStaging(String orgTrace, String prodCode,Date oriBizDate) throws Exception { + Map paramMap = new HashMap<>(); + paramMap.put("orgId", CommonSysConst.getSysConfig().getUnionStagingPayOrgId()); + paramMap.put("orgMerCode", CommonSysConst.getSysConfig().getUnionStagingPayOrgMerCode()); + paramMap.put("orgTermNo", CommonSysConst.getSysConfig().getUnionStagingPayOrgTermNo()); + paramMap.put("orgTrace", orgTrace); + paramMap.put("prodCode", "ISYH"); + paramMap.put("signType", "RSA"); + + Map bizDataMap = new HashMap<>(); + bizDataMap.put("oriOrgTrace", orgTrace); + bizDataMap.put("oriBizDate", DateUtil.date2String(oriBizDate, "yyyyMMdd")); + paramMap.put("bizData", bizDataMap); + paramMap.put("sign", generateSign(bizDataMap)); + + JSONObject responseParam = HttpsUtils.doPost(CommonSysConst.getSysConfig().getUnionStagingPayUrl()+"cashier/trade/queryStaging", paramMap, new HashMap<>()); + return responseParam; + } + /** * 参数排序 * @param param diff --git a/hai-service/src/main/resources/dev/commonConfig.properties b/hai-service/src/main/resources/dev/commonConfig.properties index fffb5593..6add75f1 100644 --- a/hai-service/src/main/resources/dev/commonConfig.properties +++ b/hai-service/src/main/resources/dev/commonConfig.properties @@ -42,7 +42,7 @@ unionStagingPayOrgId=ORG000000000001 unionStagingPayOrgMerCode=890000000123679 unionStagingPayOrgTermNo=W0616228 unionStagingPaySignKey=1dfk0i0fl7ild07l2k5oj8dddikkivd0 -unionStagingPayNotifyUrl=https://hsgcs.dctpay.com/crest/unionPay/notify +unionStagingPayNotifyUrl=https://hsgcs.dctpay.com/crest/unionPay/stagingNotify # ?????? wx_cert=/home/project/wx_cert/ diff --git a/hai-service/src/main/resources/pre/commonConfig.properties b/hai-service/src/main/resources/pre/commonConfig.properties index fd7aa739..a97d4c4f 100644 --- a/hai-service/src/main/resources/pre/commonConfig.properties +++ b/hai-service/src/main/resources/pre/commonConfig.properties @@ -30,6 +30,13 @@ unionPaySignKey=sa72ivadl84273dlj2kdaia2idiadik5 unionPayNotifyUrl=https://hsg.dctpay.com/crest/unionPay/notify unionPayTelNotifyUrl=https://hsg.dctpay.com/crest/unionPay/notifyTel +unionStagingPayUrl=https://mtest.eycard.cn/ +unionStagingPayOrgId=ORG000000000001 +unionStagingPayOrgMerCode=890000000123679 +unionStagingPayOrgTermNo=W0616228 +unionStagingPaySignKey=1dfk0i0fl7ild07l2k5oj8dddikkivd0 +unionStagingPayNotifyUrl=https://hsgcs.dctpay.com/crest/unionPay/stagingNotify + wx_cert=/home/project/wx_cert/ TelApiKey=2d01f6b520254b1a80f6b167832cea18 diff --git a/hai-service/src/main/resources/prod-9401/commonConfig.properties b/hai-service/src/main/resources/prod-9401/commonConfig.properties index feaaa8b7..3f5def1b 100644 --- a/hai-service/src/main/resources/prod-9401/commonConfig.properties +++ b/hai-service/src/main/resources/prod-9401/commonConfig.properties @@ -30,6 +30,13 @@ unionPaySignKey=1dfk0i0fl7ild07l2k5oj8dddikkivd0 unionPayNotifyUrl=https://hsg.dctpay.com/crest/unionPay/notify unionPayTelNotifyUrl=https://hsg.dctpay.com/crest/unionPay/notifyTel +unionStagingPayUrl=https://mtest.eycard.cn/ +unionStagingPayOrgId=ORG000000000001 +unionStagingPayOrgMerCode=890000000123679 +unionStagingPayOrgTermNo=W0616228 +unionStagingPaySignKey=1dfk0i0fl7ild07l2k5oj8dddikkivd0 +unionStagingPayNotifyUrl=https://hsgcs.dctpay.com/crest/unionPay/stagingNotify + wx_cert=/home/project/wx_cert/ TelApiKey=2d01f6b520254b1a80f6b167832cea18 diff --git a/hai-service/src/main/resources/prod/commonConfig.properties b/hai-service/src/main/resources/prod/commonConfig.properties index feaaa8b7..3f5def1b 100644 --- a/hai-service/src/main/resources/prod/commonConfig.properties +++ b/hai-service/src/main/resources/prod/commonConfig.properties @@ -30,6 +30,13 @@ unionPaySignKey=1dfk0i0fl7ild07l2k5oj8dddikkivd0 unionPayNotifyUrl=https://hsg.dctpay.com/crest/unionPay/notify unionPayTelNotifyUrl=https://hsg.dctpay.com/crest/unionPay/notifyTel +unionStagingPayUrl=https://mtest.eycard.cn/ +unionStagingPayOrgId=ORG000000000001 +unionStagingPayOrgMerCode=890000000123679 +unionStagingPayOrgTermNo=W0616228 +unionStagingPaySignKey=1dfk0i0fl7ild07l2k5oj8dddikkivd0 +unionStagingPayNotifyUrl=https://hsgcs.dctpay.com/crest/unionPay/stagingNotify + wx_cert=/home/project/wx_cert/ TelApiKey=2d01f6b520254b1a80f6b167832cea18 From 046a942cde9f4fb63f883d03125bfffce0a1515e Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Wed, 15 Dec 2021 16:27:33 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cweb/controller/HighTestController.java | 2 +- .../com/hai/config/UnionStagingPayConfig.java | 47 +++++++++++++++++-- 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighTestController.java b/hai-cweb/src/main/java/com/cweb/controller/HighTestController.java index c7540392..35d32e41 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighTestController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighTestController.java @@ -1 +1 @@ -package com.cweb.controller; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.cweb.config.SysConst; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.pay.util.XmlUtil; import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.utils.*; import com.hai.config.*; import com.hai.dao.HighGasOrderPushMapper; import com.hai.entity.*; import com.hai.model.*; import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.ssl.SSLContexts; import org.apache.http.util.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Controller; import org.springframework.util.IdGenerator; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.net.ssl.SSLContext; import java.io.FileInputStream; import java.math.BigDecimal; import java.security.KeyStore; import java.util.*; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/test") @Api(value = "订单接口") public class HighTestController { private static Logger log = LoggerFactory.getLogger(HighTestController.class); @Resource private HighMerchantService highMerchantService; @Resource private HighMerchantStoreService highMerchantStoreService; @Resource private HighGasOilPriceService highGasOilPriceService; @Resource private HighOrderService highOrderService; @Resource private HighProfitSharingRecordService highProfitSharingRecordService; @Resource private HighGasOrderPushMapper highGasOrderPushMapper; @Resource private HuiLianTongConfig huiLianTongConfig; @Resource private UnionPayConfig unionPayConfig; @Resource private UnionUserConfig unionUserConfig; @RequestMapping(value = "/initTYMerchantStore", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "初始化加油站") public ResponseData initTYMerchantStore(@RequestParam(name = "merchantId", required = true) Long merchantId) throws Exception { HighMerchantModel merchant = highMerchantService.getMerchantById(merchantId); if (merchant == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到商户"); } JSONObject jsonObjectP = TuanYouConfig.queryGasInfoListByPage(1, 1000); JSONObject resultObjectP = jsonObjectP.getObject("result", JSONObject.class); for (int i = 1; i <= resultObjectP.getInteger("totalPageNum").intValue();i++) { JSONObject jsonObject = TuanYouConfig.queryGasInfoListByPage(i, 1000); JSONObject resultObject = jsonObject.getObject("result", JSONObject.class); JSONArray jsonArray = resultObject.getJSONArray("gasInfoList"); HighMerchantStore highMerchantStore; HighGasOilPrice highGasOilPrice; for (Object gasObject : jsonArray) { JSONObject object = JSONObject.parseObject(JSONObject.toJSONString(gasObject)); HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreByKey(object.getString("gasId")); if (store != null) { store.setType(1); store.setMerchantId(merchant.getId()); store.setCompanyId(merchant.getCompanyId()); store.setStoreKey(object.getString("gasId")); store.setStoreName(object.getString("gasName")); store.setStoreLogo(object.getString("gasLogoSmall")); store.setRegionId(object.getLong("provinceCode")); store.setRegionName(object.getString("provinceName")); store.setAddress(object.getString("gasAddress")); store.setLongitude(object.getString("gasAddressLongitude")); store.setLatitude(object.getString("gasAddressLatitude")); store.setStatus(object.getInteger("gasStatus")); store.setOperatorId(0L); store.setOperatorName("系统创建"); store.setUpdateTime(new Date()); store.setExt1(object.getString("gasSourceId")); highMerchantStoreService.updateMerchantStoreDetail(store); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); // 查询门店油号 highGasOilPrice = highGasOilPriceService.getGasOilPriceByStoreAndOilNo(store.getId(), oilPriceObject.getInteger("oilNo")); if (highGasOilPrice == null) { highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); } else { highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); } highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } else { highMerchantStore = new HighMerchantStore(); highMerchantStore.setType(1); highMerchantStore.setMerchantId(merchant.getId()); highMerchantStore.setCompanyId(merchant.getCompanyId()); highMerchantStore.setStoreKey(object.getString("gasId")); highMerchantStore.setStoreName(object.getString("gasName")); highMerchantStore.setStoreLogo(object.getString("gasLogoSmall")); highMerchantStore.setRegionId(object.getLong("provinceCode")); highMerchantStore.setRegionName(object.getString("provinceName")); highMerchantStore.setAddress(object.getString("gasAddress")); highMerchantStore.setLongitude(object.getString("gasAddressLongitude")); highMerchantStore.setLatitude(object.getString("gasAddressLatitude")); highMerchantStore.setStatus(1); highMerchantStore.setOperatorId(0L); highMerchantStore.setOperatorName("系统创建"); highMerchantStore.setCreateTime(new Date()); highMerchantStore.setUpdateTime(new Date()); highMerchantStore.setExt1(object.getString("gasSourceId")); HighMerchantStoreModel merchantStoreModel = new HighMerchantStoreModel(); BeanUtils.copyProperties(highMerchantStore, merchantStoreModel); highMerchantStoreService.insertMerchantStore(merchantStoreModel); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(merchantStoreModel.getId()); highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } } } return ResponseMsgUtil.success("初始化完成"); } @RequestMapping(value = "/pushTuanYouOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "推送团油订单") public ResponseData pushTuanYouOrder() { try { HighOrder order = highOrderService.getOrderByOrderNo("HF2021102112141171406"); for (HighChildOrder highChildOrder : order.getHighChildOrderList()) { HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreById(highChildOrder.getGoodsId()); // 推送团油订单 Map paramMap = new HashMap<>(); paramMap.put("gasId", store.getStoreKey()); paramMap.put("oilNo", highChildOrder.getGasOilNo()); paramMap.put("gunNo", highChildOrder.getGasGunNo()); BigDecimal priceGun = highChildOrder.getGasPriceGun(); BigDecimal priceVip = highChildOrder.getGasPriceVip(); paramMap.put("priceGun", priceGun); // 枪单价 paramMap.put("priceVip", priceVip); // 优惠价 paramMap.put("driverPhone", order.getMemPhone()); // paramMap.put("driverPhone", "17726395120"); paramMap.put("thirdSerialNo", order.getOrderNo()); paramMap.put("refuelingAmount", highChildOrder.getTotalPrice()); // 油品类型 1:汽油:2:柴油;3:天然气 if (highChildOrder.getGasOilType() == 1) { paramMap.put("accountNo", CommonSysConst.getSysConfig().getTuanYouGasolineAccount()); } else if (highChildOrder.getGasOilType() == 2) { paramMap.put("accountNo", CommonSysConst.getSysConfig().getTuanYouDieselAccount()); } JSONObject orderPushObject = TuanYouConfig.refuelingOrderPush(paramMap); // 推送团油订单记录 HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); highGasOrderPush.setCreateTime(new Date()); highGasOrderPush.setCode(orderPushObject.getString("code")); highGasOrderPush.setRequestContent(JSONObject.toJSONString(paramMap)); highGasOrderPush.setReturnContent(orderPushObject.toJSONString()); highGasOrderPushMapper.insert(highGasOrderPush); if (orderPushObject != null && orderPushObject.getString("code").equals("200")) { highChildOrder.setGasOrderNo(orderPushObject.getJSONObject("result").getString("orderNo")); } highOrderService.updateOrder(order); } return ResponseMsgUtil.success(order); } catch (Exception e) { log.error("HighOrderController --> getOrderById() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryCompanyAccountInfo2JD", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询团油余额") public ResponseData queryCompanyAccountInfo2JD() { try { return ResponseMsgUtil.success(TuanYouConfig.queryCompanyAccountInfo2JD()); } catch (Exception e) { log.error("HighOrderController --> queryCompanyAccountInfo2JD() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/couJointDist", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "派发贵州卡券") public ResponseData couJointDist(@RequestParam(name = "token", required = true) String token) { try { return ResponseMsgUtil.success(HuiLianTongConfig.couJointDist(token,"HF"+System.currentTimeMillis(),"20JY000251",2,"17726395120", "oArhO6XxKSvjI9wLP3cTK-iSG8yY")); } catch (Exception e) { log.error("HighOrderController --> getOrderById() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/unionPay", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "银联支付") public ResponseData unionPay() { try { return ResponseMsgUtil.success(unionPayConfig.upPreOrder("HF"+System.currentTimeMillis(), new BigDecimal("1"), "test",CommonSysConst.getSysConfig().getUnionPayNotifyUrl())); } catch (Exception e) { log.error("HighOrderController --> getOrderById() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getToken", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取贵州中石化token") public ResponseData getToken() { try { return ResponseMsgUtil.success(huiLianTongConfig.getToken()); } catch (Exception e) { log.error("HighOrderController --> getToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/unionTradeQuery", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "银联交易查询") public ResponseData unionTradeQuery(@RequestParam(name = "paySerialNo", required = true) String paySerialNo) { try { return ResponseMsgUtil.success(UnionPayConfig.tradeQuery(paySerialNo)); } catch (Exception e) { log.error("HighOrderController --> unionTradeQuery() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getBackendToken", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取访问令牌backendToken") public ResponseData getBackendToken() { try { return ResponseMsgUtil.success(unionUserConfig.getBackendToken()); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/wxSplitAccount", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "微信分账") public ResponseData wxSplitAccount() { try { HighOrder orderNo = highOrderService.getOrderByOrderNo("HF2021101812025050304"); wxProfitsharing(orderNo.getOrderNo(),orderNo.getPaySerialNo(),orderNo.getPayRealPrice()); return ResponseMsgUtil.success("分账成功"); } catch (Exception e) { log.error("HighOrderController --> getOrderById() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/unionStagingPay", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "银联分期支付") public ResponseData unionStagingPay() { try { /* String orderNo = DateUtil.format(new Date(), DateUtil.YMDHMS); orderNo += IDGenerator.nextId(28 - orderNo.length());*/ String orgTrace = CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(0,4) +CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length() - 4,CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length()) +DateUtil.format(new Date(), DateUtil.YMDHMS) +IDGenerator.nextId(6); return ResponseMsgUtil.success(UnionStagingPayConfig.advancePay( orgTrace, orgTrace, new BigDecimal("1"), "62285", "c8BHfKVs6l68BBP9KD9jz4QLJCd/IKW/D+EsM0BLKzb/E7l8k4+aO/Y/h5j89s1X", CommonSysConst.getSysConfig().getUnionStagingPayNotifyUrl())); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryStaging", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "银联分期支付") public ResponseData queryStaging(@RequestParam(name = "orgTrace", required = true) String orgTrace) { try { return ResponseMsgUtil.success(UnionStagingPayConfig.queryStaging(orgTrace, "", new Date())); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } public void wxProfitsharing(String transaction_id,String out_order_no, BigDecimal amount) { try { Map param = new LinkedHashMap<>(); param.put("appid", "wx637bd6f7314daa46"); param.put("mch_id", "1289663601"); param.put("sub_mch_id" , "1609882817"); // 个体户黎杨珍 param.put("transaction_id" , transaction_id); param.put("out_order_no" , out_order_no); param.put("nonce_str" , WxUtils.makeNonStr()); // 分账金额 BigDecimal porofitSharingAmount = amount; List> receiversList = new ArrayList<>(); Map receiversMap = new LinkedHashMap<>(); receiversMap.put("type", "MERCHANT_ID"); receiversMap.put("account", "1603942866"); receiversMap.put("amount", porofitSharingAmount.multiply(new BigDecimal("100")).intValue()); receiversMap.put("description", "分给商户【惠昕石化】"); receiversList.add(receiversMap); param.put("receivers" , JSONObject.toJSONString(receiversList)); String signStr = WxUtils.generateSignature(param, "Skufk5oi85wDFGl888i6wsRSTkdd5df5" , WXPayConstants.SignType.HMACSHA256); param.put("sign" , signStr); String resultXmL = this.doRefundRequest(param.get("mch_id"),null, WxUtils.mapToXml(param)); // 请求分账返回的结果 ResultProfitSharing resultProfitSharing = XmlUtil.getObjectFromXML(resultXmL, ResultProfitSharing.class); if (!resultProfitSharing.getResult_code().equals("FAIL")) { HighProfitSharingRecord sharingRecord = new HighProfitSharingRecord(); sharingRecord.setOutOrderNo(resultProfitSharing.getOut_order_no()); sharingRecord.setTransactionId(resultProfitSharing.getTransaction_id()); sharingRecord.setOrderId(resultProfitSharing.getOrder_id()); sharingRecord.setStatus(resultProfitSharing.getResult_code()); sharingRecord.setPrice(amount); sharingRecord.setCreateTime(new Date()); sharingRecord.setContent(resultXmL); highProfitSharingRecordService.insert(sharingRecord); } } catch (Exception e) { log.error("CmsContentController --> getCorporateAdvertising() error!", e); } } public CloseableHttpClient readCertificate(String mchId) throws Exception{ /** * 注意PKCS12证书 是从微信商户平台-》账户设置-》 API安全 中下载的 */ KeyStore keyStore = KeyStore.getInstance("PKCS12"); //P12文件目录 证书路径,这里需要你自己修改,linux下还是windows下的根路径 FileInputStream instream = new FileInputStream("/home/project/wx_cert/1289663601_apiclient_cert.p12"); // FileInputStream instream = new FileInputStream("G:\\hurui-project/hai-parent/hai-service/src/main/java/privatekey/1289663601_apiclient_cert.p12"); try { keyStore.load(instream, "1289663601".toCharArray());//这里写密码..默认是你的MCHID } finally { instream.close(); } SSLContext sslcontext = SSLContexts.custom().loadKeyMaterial(keyStore, "1289663601".toCharArray()).build();//这里也是写密码的 SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslcontext, SSLConnectionSocketFactory.getDefaultHostnameVerifier()); // Allow TLSv1 protocol only return HttpClients.custom().setSSLSocketFactory(sslsf).build(); } public String doRefundRequest(String mchId, String url, String data) throws Exception { //小程序退款需要调用双向证书的认证 CloseableHttpClient httpClient = readCertificate(mchId); try { HttpPost httpost = new HttpPost("https://api.mch.weixin.qq.com/secapi/pay/refund"); // 设置响应头信息 httpost.addHeader("Connection", "keep-alive"); httpost.addHeader("Accept", "*/*"); httpost.addHeader("Content-Type", "text/xml"); httpost.addHeader("Host", "api.mch.weixin.qq.com"); httpost.addHeader("X-Requested-With", "XMLHttpRequest"); httpost.addHeader("Cache-Control", "max-age=0"); httpost.addHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0) "); httpost.setEntity(new StringEntity(data, "UTF-8")); CloseableHttpResponse response = httpClient.execute(httpost); try { HttpEntity entity = response.getEntity(); String jsonStr = EntityUtils.toString(response.getEntity(), "UTF-8"); EntityUtils.consume(entity); return jsonStr; } finally { response.close(); } } catch (Exception e){ throw new RuntimeException(e); } finally { httpClient.close(); } } } \ No newline at end of file +package com.cweb.controller; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.cweb.config.SysConst; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.pay.util.XmlUtil; import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.utils.*; import com.hai.config.*; import com.hai.dao.HighGasOrderPushMapper; import com.hai.entity.*; import com.hai.model.*; import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.ssl.SSLContexts; import org.apache.http.util.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Controller; import org.springframework.util.IdGenerator; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.net.ssl.SSLContext; import java.io.FileInputStream; import java.math.BigDecimal; import java.security.KeyStore; import java.util.*; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/test") @Api(value = "订单接口") public class HighTestController { private static Logger log = LoggerFactory.getLogger(HighTestController.class); @Resource private HighMerchantService highMerchantService; @Resource private HighMerchantStoreService highMerchantStoreService; @Resource private HighGasOilPriceService highGasOilPriceService; @Resource private HighOrderService highOrderService; @Resource private HighProfitSharingRecordService highProfitSharingRecordService; @Resource private HighGasOrderPushMapper highGasOrderPushMapper; @Resource private HuiLianTongConfig huiLianTongConfig; @Resource private UnionPayConfig unionPayConfig; @Resource private UnionUserConfig unionUserConfig; @RequestMapping(value = "/initTYMerchantStore", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "初始化加油站") public ResponseData initTYMerchantStore(@RequestParam(name = "merchantId", required = true) Long merchantId) throws Exception { HighMerchantModel merchant = highMerchantService.getMerchantById(merchantId); if (merchant == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到商户"); } JSONObject jsonObjectP = TuanYouConfig.queryGasInfoListByPage(1, 1000); JSONObject resultObjectP = jsonObjectP.getObject("result", JSONObject.class); for (int i = 1; i <= resultObjectP.getInteger("totalPageNum").intValue();i++) { JSONObject jsonObject = TuanYouConfig.queryGasInfoListByPage(i, 1000); JSONObject resultObject = jsonObject.getObject("result", JSONObject.class); JSONArray jsonArray = resultObject.getJSONArray("gasInfoList"); HighMerchantStore highMerchantStore; HighGasOilPrice highGasOilPrice; for (Object gasObject : jsonArray) { JSONObject object = JSONObject.parseObject(JSONObject.toJSONString(gasObject)); HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreByKey(object.getString("gasId")); if (store != null) { store.setType(1); store.setMerchantId(merchant.getId()); store.setCompanyId(merchant.getCompanyId()); store.setStoreKey(object.getString("gasId")); store.setStoreName(object.getString("gasName")); store.setStoreLogo(object.getString("gasLogoSmall")); store.setRegionId(object.getLong("provinceCode")); store.setRegionName(object.getString("provinceName")); store.setAddress(object.getString("gasAddress")); store.setLongitude(object.getString("gasAddressLongitude")); store.setLatitude(object.getString("gasAddressLatitude")); store.setStatus(object.getInteger("gasStatus")); store.setOperatorId(0L); store.setOperatorName("系统创建"); store.setUpdateTime(new Date()); store.setExt1(object.getString("gasSourceId")); highMerchantStoreService.updateMerchantStoreDetail(store); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); // 查询门店油号 highGasOilPrice = highGasOilPriceService.getGasOilPriceByStoreAndOilNo(store.getId(), oilPriceObject.getInteger("oilNo")); if (highGasOilPrice == null) { highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); } else { highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); } highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } else { highMerchantStore = new HighMerchantStore(); highMerchantStore.setType(1); highMerchantStore.setMerchantId(merchant.getId()); highMerchantStore.setCompanyId(merchant.getCompanyId()); highMerchantStore.setStoreKey(object.getString("gasId")); highMerchantStore.setStoreName(object.getString("gasName")); highMerchantStore.setStoreLogo(object.getString("gasLogoSmall")); highMerchantStore.setRegionId(object.getLong("provinceCode")); highMerchantStore.setRegionName(object.getString("provinceName")); highMerchantStore.setAddress(object.getString("gasAddress")); highMerchantStore.setLongitude(object.getString("gasAddressLongitude")); highMerchantStore.setLatitude(object.getString("gasAddressLatitude")); highMerchantStore.setStatus(1); highMerchantStore.setOperatorId(0L); highMerchantStore.setOperatorName("系统创建"); highMerchantStore.setCreateTime(new Date()); highMerchantStore.setUpdateTime(new Date()); highMerchantStore.setExt1(object.getString("gasSourceId")); HighMerchantStoreModel merchantStoreModel = new HighMerchantStoreModel(); BeanUtils.copyProperties(highMerchantStore, merchantStoreModel); highMerchantStoreService.insertMerchantStore(merchantStoreModel); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(merchantStoreModel.getId()); highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } } } return ResponseMsgUtil.success("初始化完成"); } @RequestMapping(value = "/pushTuanYouOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "推送团油订单") public ResponseData pushTuanYouOrder() { try { HighOrder order = highOrderService.getOrderByOrderNo("HF2021102112141171406"); for (HighChildOrder highChildOrder : order.getHighChildOrderList()) { HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreById(highChildOrder.getGoodsId()); // 推送团油订单 Map paramMap = new HashMap<>(); paramMap.put("gasId", store.getStoreKey()); paramMap.put("oilNo", highChildOrder.getGasOilNo()); paramMap.put("gunNo", highChildOrder.getGasGunNo()); BigDecimal priceGun = highChildOrder.getGasPriceGun(); BigDecimal priceVip = highChildOrder.getGasPriceVip(); paramMap.put("priceGun", priceGun); // 枪单价 paramMap.put("priceVip", priceVip); // 优惠价 paramMap.put("driverPhone", order.getMemPhone()); // paramMap.put("driverPhone", "17726395120"); paramMap.put("thirdSerialNo", order.getOrderNo()); paramMap.put("refuelingAmount", highChildOrder.getTotalPrice()); // 油品类型 1:汽油:2:柴油;3:天然气 if (highChildOrder.getGasOilType() == 1) { paramMap.put("accountNo", CommonSysConst.getSysConfig().getTuanYouGasolineAccount()); } else if (highChildOrder.getGasOilType() == 2) { paramMap.put("accountNo", CommonSysConst.getSysConfig().getTuanYouDieselAccount()); } JSONObject orderPushObject = TuanYouConfig.refuelingOrderPush(paramMap); // 推送团油订单记录 HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); highGasOrderPush.setCreateTime(new Date()); highGasOrderPush.setCode(orderPushObject.getString("code")); highGasOrderPush.setRequestContent(JSONObject.toJSONString(paramMap)); highGasOrderPush.setReturnContent(orderPushObject.toJSONString()); highGasOrderPushMapper.insert(highGasOrderPush); if (orderPushObject != null && orderPushObject.getString("code").equals("200")) { highChildOrder.setGasOrderNo(orderPushObject.getJSONObject("result").getString("orderNo")); } highOrderService.updateOrder(order); } return ResponseMsgUtil.success(order); } catch (Exception e) { log.error("HighOrderController --> getOrderById() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryCompanyAccountInfo2JD", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询团油余额") public ResponseData queryCompanyAccountInfo2JD() { try { return ResponseMsgUtil.success(TuanYouConfig.queryCompanyAccountInfo2JD()); } catch (Exception e) { log.error("HighOrderController --> queryCompanyAccountInfo2JD() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/couJointDist", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "派发贵州卡券") public ResponseData couJointDist(@RequestParam(name = "token", required = true) String token) { try { return ResponseMsgUtil.success(HuiLianTongConfig.couJointDist(token,"HF"+System.currentTimeMillis(),"20JY000251",2,"17726395120", "oArhO6XxKSvjI9wLP3cTK-iSG8yY")); } catch (Exception e) { log.error("HighOrderController --> getOrderById() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/unionPay", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "银联支付") public ResponseData unionPay() { try { return ResponseMsgUtil.success(unionPayConfig.upPreOrder("HF"+System.currentTimeMillis(), new BigDecimal("1"), "test",CommonSysConst.getSysConfig().getUnionPayNotifyUrl())); } catch (Exception e) { log.error("HighOrderController --> getOrderById() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getToken", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取贵州中石化token") public ResponseData getToken() { try { return ResponseMsgUtil.success(huiLianTongConfig.getToken()); } catch (Exception e) { log.error("HighOrderController --> getToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/unionTradeQuery", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "银联交易查询") public ResponseData unionTradeQuery(@RequestParam(name = "paySerialNo", required = true) String paySerialNo) { try { return ResponseMsgUtil.success(UnionPayConfig.tradeQuery(paySerialNo)); } catch (Exception e) { log.error("HighOrderController --> unionTradeQuery() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getBackendToken", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取访问令牌backendToken") public ResponseData getBackendToken() { try { return ResponseMsgUtil.success(unionUserConfig.getBackendToken()); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/wxSplitAccount", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "微信分账") public ResponseData wxSplitAccount() { try { HighOrder orderNo = highOrderService.getOrderByOrderNo("HF2021101812025050304"); wxProfitsharing(orderNo.getOrderNo(),orderNo.getPaySerialNo(),orderNo.getPayRealPrice()); return ResponseMsgUtil.success("分账成功"); } catch (Exception e) { log.error("HighOrderController --> getOrderById() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/unionStagingPay", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "银联分期支付") public ResponseData unionStagingPay() { try { /* String orderNo = DateUtil.format(new Date(), DateUtil.YMDHMS); orderNo += IDGenerator.nextId(28 - orderNo.length());*/ String orgTrace = CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(0,4) +CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length() - 4,CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length()) +DateUtil.format(new Date(), DateUtil.YMDHMS) +IDGenerator.nextId(6); return ResponseMsgUtil.success(UnionStagingPayConfig.advancePay( orgTrace, orgTrace, new BigDecimal("1"), "62285", "c8BHfKVs6l68BBP9KD9jz4QLJCd/IKW/D+EsM0BLKzb/E7l8k4+aO/Y/h5j89s1X", CommonSysConst.getSysConfig().getUnionStagingPayNotifyUrl())); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryStaging", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "分期查询") public ResponseData queryStaging(@RequestParam(name = "oriOrgTrace", required = true) String oriOrgTrace) { try { String orgTrace = CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(0,4) +CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length() - 4,CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length()) +DateUtil.format(new Date(), DateUtil.YMDHMS) +IDGenerator.nextId(6); return ResponseMsgUtil.success(UnionStagingPayConfig.queryStaging(orgTrace,oriOrgTrace ,"", new Date())); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/query", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "订单查询") public ResponseData query(@RequestParam(name = "oriOrgTrace", required = true) String oriOrgTrace) { try { String orgTrace = CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(0,4) +CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length() - 4,CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length()) +DateUtil.format(new Date(), DateUtil.YMDHMS) +IDGenerator.nextId(6); return ResponseMsgUtil.success(UnionStagingPayConfig.query(orgTrace,oriOrgTrace ,"", new Date())); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/mposrefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "分期退款") public ResponseData mposrefund(@RequestParam(name = "oriOrgTrace", required = true) String oriOrgTrace) { try { String orgTrace = CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(0,4) +CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length() - 4,CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length()) +DateUtil.format(new Date(), DateUtil.YMDHMS) +IDGenerator.nextId(6); return ResponseMsgUtil.success(UnionStagingPayConfig.mposrefund(orgTrace,oriOrgTrace ,new BigDecimal("1"), "", new Date())); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/mposfindrefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "分期退款查询") public ResponseData mposfindrefund(@RequestParam(name = "oriOrgTrace", required = true) String oriOrgTrace) { try { String orgTrace = CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(0,4) +CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length() - 4,CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length()) +DateUtil.format(new Date(), DateUtil.YMDHMS) +IDGenerator.nextId(6); return ResponseMsgUtil.success(UnionStagingPayConfig.mposfindrefund(orgTrace,oriOrgTrace ,"", new Date())); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } public void wxProfitsharing(String transaction_id,String out_order_no, BigDecimal amount) { try { Map param = new LinkedHashMap<>(); param.put("appid", "wx637bd6f7314daa46"); param.put("mch_id", "1289663601"); param.put("sub_mch_id" , "1609882817"); // 个体户黎杨珍 param.put("transaction_id" , transaction_id); param.put("out_order_no" , out_order_no); param.put("nonce_str" , WxUtils.makeNonStr()); // 分账金额 BigDecimal porofitSharingAmount = amount; List> receiversList = new ArrayList<>(); Map receiversMap = new LinkedHashMap<>(); receiversMap.put("type", "MERCHANT_ID"); receiversMap.put("account", "1603942866"); receiversMap.put("amount", porofitSharingAmount.multiply(new BigDecimal("100")).intValue()); receiversMap.put("description", "分给商户【惠昕石化】"); receiversList.add(receiversMap); param.put("receivers" , JSONObject.toJSONString(receiversList)); String signStr = WxUtils.generateSignature(param, "Skufk5oi85wDFGl888i6wsRSTkdd5df5" , WXPayConstants.SignType.HMACSHA256); param.put("sign" , signStr); String resultXmL = this.doRefundRequest(param.get("mch_id"),null, WxUtils.mapToXml(param)); // 请求分账返回的结果 ResultProfitSharing resultProfitSharing = XmlUtil.getObjectFromXML(resultXmL, ResultProfitSharing.class); if (!resultProfitSharing.getResult_code().equals("FAIL")) { HighProfitSharingRecord sharingRecord = new HighProfitSharingRecord(); sharingRecord.setOutOrderNo(resultProfitSharing.getOut_order_no()); sharingRecord.setTransactionId(resultProfitSharing.getTransaction_id()); sharingRecord.setOrderId(resultProfitSharing.getOrder_id()); sharingRecord.setStatus(resultProfitSharing.getResult_code()); sharingRecord.setPrice(amount); sharingRecord.setCreateTime(new Date()); sharingRecord.setContent(resultXmL); highProfitSharingRecordService.insert(sharingRecord); } } catch (Exception e) { log.error("CmsContentController --> getCorporateAdvertising() error!", e); } } public CloseableHttpClient readCertificate(String mchId) throws Exception{ /** * 注意PKCS12证书 是从微信商户平台-》账户设置-》 API安全 中下载的 */ KeyStore keyStore = KeyStore.getInstance("PKCS12"); //P12文件目录 证书路径,这里需要你自己修改,linux下还是windows下的根路径 FileInputStream instream = new FileInputStream("/home/project/wx_cert/1289663601_apiclient_cert.p12"); // FileInputStream instream = new FileInputStream("G:\\hurui-project/hai-parent/hai-service/src/main/java/privatekey/1289663601_apiclient_cert.p12"); try { keyStore.load(instream, "1289663601".toCharArray());//这里写密码..默认是你的MCHID } finally { instream.close(); } SSLContext sslcontext = SSLContexts.custom().loadKeyMaterial(keyStore, "1289663601".toCharArray()).build();//这里也是写密码的 SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslcontext, SSLConnectionSocketFactory.getDefaultHostnameVerifier()); // Allow TLSv1 protocol only return HttpClients.custom().setSSLSocketFactory(sslsf).build(); } public String doRefundRequest(String mchId, String url, String data) throws Exception { //小程序退款需要调用双向证书的认证 CloseableHttpClient httpClient = readCertificate(mchId); try { HttpPost httpost = new HttpPost("https://api.mch.weixin.qq.com/secapi/pay/refund"); // 设置响应头信息 httpost.addHeader("Connection", "keep-alive"); httpost.addHeader("Accept", "*/*"); httpost.addHeader("Content-Type", "text/xml"); httpost.addHeader("Host", "api.mch.weixin.qq.com"); httpost.addHeader("X-Requested-With", "XMLHttpRequest"); httpost.addHeader("Cache-Control", "max-age=0"); httpost.addHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0) "); httpost.setEntity(new StringEntity(data, "UTF-8")); CloseableHttpResponse response = httpClient.execute(httpost); try { HttpEntity entity = response.getEntity(); String jsonStr = EntityUtils.toString(response.getEntity(), "UTF-8"); EntityUtils.consume(entity); return jsonStr; } finally { response.close(); } } catch (Exception e){ throw new RuntimeException(e); } finally { httpClient.close(); } } } \ No newline at end of file diff --git a/hai-service/src/main/java/com/hai/config/UnionStagingPayConfig.java b/hai-service/src/main/java/com/hai/config/UnionStagingPayConfig.java index af26ce53..1a8858a9 100644 --- a/hai-service/src/main/java/com/hai/config/UnionStagingPayConfig.java +++ b/hai-service/src/main/java/com/hai/config/UnionStagingPayConfig.java @@ -56,7 +56,7 @@ public class UnionStagingPayConfig { return responseParam; } - public static JSONObject query(String orgTrace, String prodCode) throws Exception { + public static JSONObject query(String orgTrace, String oriOrgTrace,String prodCode,Date oriBizDate) throws Exception { Map paramMap = new HashMap<>(); paramMap.put("orgId", CommonSysConst.getSysConfig().getUnionStagingPayOrgId()); paramMap.put("orgMerCode", CommonSysConst.getSysConfig().getUnionStagingPayOrgMerCode()); @@ -66,8 +66,8 @@ public class UnionStagingPayConfig { paramMap.put("signType", "RSA"); Map bizDataMap = new HashMap<>(); - bizDataMap.put("oriOrgTrace", null); - bizDataMap.put("oriBizDate", null); + bizDataMap.put("oriOrgTrace", oriOrgTrace); + bizDataMap.put("oriBizDate", DateUtil.date2String(oriBizDate, "yyyyMMdd")); paramMap.put("bizData", bizDataMap); paramMap.put("sign", generateSign(bizDataMap)); @@ -75,7 +75,7 @@ public class UnionStagingPayConfig { return responseParam; } - public static JSONObject queryStaging(String orgTrace, String prodCode,Date oriBizDate) throws Exception { + public static JSONObject queryStaging(String orgTrace, String oriOrgTrace, String prodCode,Date oriBizDate) throws Exception { Map paramMap = new HashMap<>(); paramMap.put("orgId", CommonSysConst.getSysConfig().getUnionStagingPayOrgId()); paramMap.put("orgMerCode", CommonSysConst.getSysConfig().getUnionStagingPayOrgMerCode()); @@ -85,7 +85,7 @@ public class UnionStagingPayConfig { paramMap.put("signType", "RSA"); Map bizDataMap = new HashMap<>(); - bizDataMap.put("oriOrgTrace", orgTrace); + bizDataMap.put("oriOrgTrace", oriOrgTrace); bizDataMap.put("oriBizDate", DateUtil.date2String(oriBizDate, "yyyyMMdd")); paramMap.put("bizData", bizDataMap); paramMap.put("sign", generateSign(bizDataMap)); @@ -94,6 +94,43 @@ public class UnionStagingPayConfig { return responseParam; } + public static JSONObject mposrefund(String orgTrace, String oriOrgTrace, BigDecimal transAmt,String prodCode,Date oriBizDate) throws Exception { + Map paramMap = new HashMap<>(); + paramMap.put("orgId", CommonSysConst.getSysConfig().getUnionStagingPayOrgId()); + paramMap.put("orgMerCode", CommonSysConst.getSysConfig().getUnionStagingPayOrgMerCode()); + paramMap.put("orgTermNo", CommonSysConst.getSysConfig().getUnionStagingPayOrgTermNo()); + paramMap.put("orgTrace", orgTrace); + paramMap.put("prodCode", "ISYH"); + paramMap.put("signType", "RSA"); + + Map bizDataMap = new HashMap<>(); + bizDataMap.put("oriOrgTrace", oriOrgTrace); + bizDataMap.put("oriBizDate", DateUtil.date2String(oriBizDate, "yyyyMMdd")); + bizDataMap.put("transAmt", transAmt.multiply(new BigDecimal("100")).intValue()); + paramMap.put("bizData", bizDataMap); + paramMap.put("sign", generateSign(bizDataMap)); + + JSONObject responseParam = HttpsUtils.doPost(CommonSysConst.getSysConfig().getUnionStagingPayUrl()+"ledger/mposrefund", paramMap, new HashMap<>()); + return responseParam; + } + + public static JSONObject mposfindrefund(String orgTrace, String oriOrgTrace,String prodCode,Date oriBizDate) throws Exception { + Map paramMap = new HashMap<>(); + paramMap.put("orgId", CommonSysConst.getSysConfig().getUnionStagingPayOrgId()); + paramMap.put("orgMerCode", CommonSysConst.getSysConfig().getUnionStagingPayOrgMerCode()); + paramMap.put("orgTermNo", CommonSysConst.getSysConfig().getUnionStagingPayOrgTermNo()); + paramMap.put("orgTrace", orgTrace); + paramMap.put("prodCode", "ISYH"); + paramMap.put("signType", "RSA"); + + Map bizDataMap = new HashMap<>(); + bizDataMap.put("oriOrgTrace", oriOrgTrace); + paramMap.put("bizData", bizDataMap); + paramMap.put("sign", generateSign(bizDataMap)); + JSONObject responseParam = HttpsUtils.doPost(CommonSysConst.getSysConfig().getUnionStagingPayUrl()+"ledger/mposfindrefund", paramMap, new HashMap<>()); + return responseParam; + } + /** * 参数排序 * @param param From 7a0376d0009a4b2b1622c153bcdcb9b4aff1ece5 Mon Sep 17 00:00:00 2001 From: Sum1Dream <418471657@qq.com> Date: Sun, 19 Dec 2021 13:29:21 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hai-cweb/src/main/resources/prod-9401/config.properties | 2 +- hai-cweb/src/main/resources/prod/config.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hai-cweb/src/main/resources/prod-9401/config.properties b/hai-cweb/src/main/resources/prod-9401/config.properties index 71f142a9..86c32fe7 100644 --- a/hai-cweb/src/main/resources/prod-9401/config.properties +++ b/hai-cweb/src/main/resources/prod-9401/config.properties @@ -1,4 +1,4 @@ -# ΢������ +# ??????? wxAppId=wx8d49e2f83025229d wxAppSecret=d8d6dcaef77d3b659258a01b5ddba5df diff --git a/hai-cweb/src/main/resources/prod/config.properties b/hai-cweb/src/main/resources/prod/config.properties index 71f142a9..86c32fe7 100644 --- a/hai-cweb/src/main/resources/prod/config.properties +++ b/hai-cweb/src/main/resources/prod/config.properties @@ -1,4 +1,4 @@ -# ΢������ +# ??????? wxAppId=wx8d49e2f83025229d wxAppSecret=d8d6dcaef77d3b659258a01b5ddba5df From c2951e28681f6052041d879ef7b0272365eefeda Mon Sep 17 00:00:00 2001 From: Sum1Dream <418471657@qq.com> Date: Sun, 19 Dec 2021 14:47:12 +0800 Subject: [PATCH 4/9] 1 --- .../OutRechargePriceController.java | 23 +++- .../OutRechargePriceController.java | 20 ++- .../com/hai/dao/OutRechargePriceMapper.java | 15 ++- .../hai/dao/OutRechargePriceSqlProvider.java | 28 ++++ .../java/com/hai/entity/OutRechargePrice.java | 32 +++++ .../hai/entity/OutRechargePriceExample.java | 120 ++++++++++++++++++ .../impl/OutRechargePriceServiceImpl.java | 11 +- 7 files changed, 242 insertions(+), 7 deletions(-) diff --git a/hai-bweb/src/main/java/com/bweb/controller/OutRechargePriceController.java b/hai-bweb/src/main/java/com/bweb/controller/OutRechargePriceController.java index 4ca13df9..9c52a8b9 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/OutRechargePriceController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/OutRechargePriceController.java @@ -5,10 +5,12 @@ import com.github.pagehelper.PageInfo; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; +import com.hai.common.security.SessionObject; import com.hai.common.security.UserCenter; import com.hai.common.utils.ResponseMsgUtil; import com.hai.entity.OutRechargePrice; import com.hai.model.ResponseData; +import com.hai.model.UserInfoModel; import com.hai.service.OutRechargePriceService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -43,16 +45,27 @@ public class OutRechargePriceController { @ApiOperation(value = "查询充值金额列表") public ResponseData getListOutRechargePrice( @RequestParam(value = "type", required = false) Integer type , + @RequestParam(value = "showType", required = false) Integer showType , @RequestParam(name = "pageNum", required = true) Integer pageNum, @RequestParam(name = "pageSize", required = true) Integer pageSize, HttpServletRequest request ) { try { + + SessionObject sessionObject = userCenter.getSessionObject(request); + UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); + Map map = new HashMap<>(); if (type != null ) { map.put("type", String.valueOf(type)); } + if (showType != null ) { + map.put("showType", String.valueOf(showType)); + } + + map.put("companyId" , String.valueOf(userInfoModel.getBsCompany().getId())); + PageHelper.startPage(pageNum, pageSize); List outRechargePrices = outRechargePriceService.getListRechargePrice(map); @@ -69,10 +82,14 @@ public class OutRechargePriceController { @ApiOperation(value = "新增金额") public ResponseData insertAgent(@RequestBody OutRechargePrice outRechargePrice, HttpServletRequest request) { try { + + SessionObject sessionObject = userCenter.getSessionObject(request); + UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); + if (outRechargePrice.getType() == null || outRechargePrice.getPrice() == null || outRechargePrice.getRealPrice() == null -// || outRechargePrice.getGoodsId() == null + || outRechargePrice.getShowType() == null || outRechargePrice.getSort() == null ) { log.error("SecOrganizationController -> insertPrice() error!"); @@ -80,6 +97,7 @@ public class OutRechargePriceController { } + outRechargePrice.setCompanyId(userInfoModel.getBsCompany().getId()); outRechargePrice.setCreateTime(new Date()); outRechargePrice.setStatus(0); @@ -102,7 +120,7 @@ public class OutRechargePriceController { || outRechargePrice.getId() == null || outRechargePrice.getPrice() == null || outRechargePrice.getRealPrice() == null -// || outRechargePrice.getGoodsId() == null + || outRechargePrice.getShowType() == null || outRechargePrice.getSort() == null ) { log.error("SecOrganizationController -> updatePrice() error!"); @@ -116,6 +134,7 @@ public class OutRechargePriceController { throw ErrorHelp.genException(SysCode.System, ErrorCode.UPDATE_DATA_ERROR, ""); } + outRechargePrice.setCompanyId(outRechargePrice1.getCompanyId()); outRechargePrice.setStatus(0); outRechargePrice.setCreateTime(outRechargePrice1.getCreateTime()); diff --git a/hai-cweb/src/main/java/com/cweb/controller/OutRechargePriceController.java b/hai-cweb/src/main/java/com/cweb/controller/OutRechargePriceController.java index d4948efa..90cc8087 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/OutRechargePriceController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/OutRechargePriceController.java @@ -8,10 +8,14 @@ import com.hai.common.exception.SysCode; import com.hai.common.security.SessionObject; import com.hai.common.security.UserCenter; import com.hai.common.utils.ResponseMsgUtil; +import com.hai.entity.BsCompany; import com.hai.entity.HighAgent; import com.hai.entity.OutRechargePrice; +import com.hai.entity.SecRegion; import com.hai.model.ResponseData; import com.hai.model.UserInfoModel; +import com.hai.service.BsCompanyService; +import com.hai.service.CommonService; import com.hai.service.OutRechargePriceService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -44,17 +48,31 @@ public class OutRechargePriceController { @Resource private OutRechargePriceService outRechargePriceService; + @Resource + private BsCompanyService bsCompanyService; + + @Resource + private CommonService commonService; + @RequestMapping(value = "/getListOutRechargePrice", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询充值金额列表") public ResponseData getListOutRechargePrice( - @RequestParam(value = "type", required = false) Integer type + @RequestParam(value = "type", required = false) Integer type, + @RequestParam(name = "regionId", required = true) String regionId ) { try { Map map = new HashMap<>(); + SecRegion region = commonService.getParentByRegion(Long.parseLong(regionId)); + if (region != null) { + BsCompany bsCompany = bsCompanyService.selectCompanyByRegion(region.getRegionId().toString()); + map.put("companyId", String.valueOf(bsCompany.getId())); + } + if (type != null ) { map.put("type", String.valueOf(type)); + } return ResponseMsgUtil.success( outRechargePriceService.getListRechargePriceC(map)); diff --git a/hai-service/src/main/java/com/hai/dao/OutRechargePriceMapper.java b/hai-service/src/main/java/com/hai/dao/OutRechargePriceMapper.java index 3874126e..29bbe3db 100644 --- a/hai-service/src/main/java/com/hai/dao/OutRechargePriceMapper.java +++ b/hai-service/src/main/java/com/hai/dao/OutRechargePriceMapper.java @@ -39,11 +39,13 @@ public interface OutRechargePriceMapper extends OutRechargePriceMapperExt { int deleteByPrimaryKey(Long id); @Insert({ - "insert into out_recharge_price (`type`, price, ", + "insert into out_recharge_price (`type`, show_type, ", + "company_id, price, ", "real_price, create_time, ", "goods_id, discount, sort, ", "`status`)", - "values (#{type,jdbcType=INTEGER}, #{price,jdbcType=DECIMAL}, ", + "values (#{type,jdbcType=INTEGER}, #{showType,jdbcType=INTEGER}, ", + "#{companyId,jdbcType=BIGINT}, #{price,jdbcType=DECIMAL}, ", "#{realPrice,jdbcType=DECIMAL}, #{createTime,jdbcType=TIMESTAMP}, ", "#{goodsId,jdbcType=BIGINT}, #{discount,jdbcType=REAL}, #{sort,jdbcType=INTEGER}, ", "#{status,jdbcType=INTEGER})" @@ -59,6 +61,8 @@ public interface OutRechargePriceMapper extends OutRechargePriceMapperExt { @Results({ @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), @Result(column="type", property="type", jdbcType=JdbcType.INTEGER), + @Result(column="show_type", property="showType", jdbcType=JdbcType.INTEGER), + @Result(column="company_id", property="companyId", jdbcType=JdbcType.BIGINT), @Result(column="price", property="price", jdbcType=JdbcType.DECIMAL), @Result(column="real_price", property="realPrice", jdbcType=JdbcType.DECIMAL), @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), @@ -71,13 +75,16 @@ public interface OutRechargePriceMapper extends OutRechargePriceMapperExt { @Select({ "select", - "id, `type`, price, real_price, create_time, goods_id, discount, sort, `status`", + "id, `type`, show_type, company_id, price, real_price, create_time, goods_id, ", + "discount, sort, `status`", "from out_recharge_price", "where id = #{id,jdbcType=BIGINT}" }) @Results({ @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), @Result(column="type", property="type", jdbcType=JdbcType.INTEGER), + @Result(column="show_type", property="showType", jdbcType=JdbcType.INTEGER), + @Result(column="company_id", property="companyId", jdbcType=JdbcType.BIGINT), @Result(column="price", property="price", jdbcType=JdbcType.DECIMAL), @Result(column="real_price", property="realPrice", jdbcType=JdbcType.DECIMAL), @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), @@ -100,6 +107,8 @@ public interface OutRechargePriceMapper extends OutRechargePriceMapperExt { @Update({ "update out_recharge_price", "set `type` = #{type,jdbcType=INTEGER},", + "show_type = #{showType,jdbcType=INTEGER},", + "company_id = #{companyId,jdbcType=BIGINT},", "price = #{price,jdbcType=DECIMAL},", "real_price = #{realPrice,jdbcType=DECIMAL},", "create_time = #{createTime,jdbcType=TIMESTAMP},", diff --git a/hai-service/src/main/java/com/hai/dao/OutRechargePriceSqlProvider.java b/hai-service/src/main/java/com/hai/dao/OutRechargePriceSqlProvider.java index 9d386e26..6c49248c 100644 --- a/hai-service/src/main/java/com/hai/dao/OutRechargePriceSqlProvider.java +++ b/hai-service/src/main/java/com/hai/dao/OutRechargePriceSqlProvider.java @@ -32,6 +32,14 @@ public class OutRechargePriceSqlProvider { sql.VALUES("`type`", "#{type,jdbcType=INTEGER}"); } + if (record.getShowType() != null) { + sql.VALUES("show_type", "#{showType,jdbcType=INTEGER}"); + } + + if (record.getCompanyId() != null) { + sql.VALUES("company_id", "#{companyId,jdbcType=BIGINT}"); + } + if (record.getPrice() != null) { sql.VALUES("price", "#{price,jdbcType=DECIMAL}"); } @@ -71,6 +79,8 @@ public class OutRechargePriceSqlProvider { sql.SELECT("id"); } sql.SELECT("`type`"); + sql.SELECT("show_type"); + sql.SELECT("company_id"); sql.SELECT("price"); sql.SELECT("real_price"); sql.SELECT("create_time"); @@ -103,6 +113,14 @@ public class OutRechargePriceSqlProvider { sql.SET("`type` = #{record.type,jdbcType=INTEGER}"); } + if (record.getShowType() != null) { + sql.SET("show_type = #{record.showType,jdbcType=INTEGER}"); + } + + if (record.getCompanyId() != null) { + sql.SET("company_id = #{record.companyId,jdbcType=BIGINT}"); + } + if (record.getPrice() != null) { sql.SET("price = #{record.price,jdbcType=DECIMAL}"); } @@ -141,6 +159,8 @@ public class OutRechargePriceSqlProvider { sql.SET("id = #{record.id,jdbcType=BIGINT}"); sql.SET("`type` = #{record.type,jdbcType=INTEGER}"); + sql.SET("show_type = #{record.showType,jdbcType=INTEGER}"); + sql.SET("company_id = #{record.companyId,jdbcType=BIGINT}"); sql.SET("price = #{record.price,jdbcType=DECIMAL}"); sql.SET("real_price = #{record.realPrice,jdbcType=DECIMAL}"); sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); @@ -162,6 +182,14 @@ public class OutRechargePriceSqlProvider { sql.SET("`type` = #{type,jdbcType=INTEGER}"); } + if (record.getShowType() != null) { + sql.SET("show_type = #{showType,jdbcType=INTEGER}"); + } + + if (record.getCompanyId() != null) { + sql.SET("company_id = #{companyId,jdbcType=BIGINT}"); + } + if (record.getPrice() != null) { sql.SET("price = #{price,jdbcType=DECIMAL}"); } diff --git a/hai-service/src/main/java/com/hai/entity/OutRechargePrice.java b/hai-service/src/main/java/com/hai/entity/OutRechargePrice.java index 15ced951..6048313c 100644 --- a/hai-service/src/main/java/com/hai/entity/OutRechargePrice.java +++ b/hai-service/src/main/java/com/hai/entity/OutRechargePrice.java @@ -24,6 +24,16 @@ public class OutRechargePrice implements Serializable { */ private Integer type; + /** + * 展示类型 :1 小程序 2:H5 3:银联 + */ + private Integer showType; + + /** + * 公司id + */ + private Long companyId; + /** * 金额 */ @@ -77,6 +87,22 @@ public class OutRechargePrice implements Serializable { this.type = type; } + public Integer getShowType() { + return showType; + } + + public void setShowType(Integer showType) { + this.showType = showType; + } + + public Long getCompanyId() { + return companyId; + } + + public void setCompanyId(Long companyId) { + this.companyId = companyId; + } + public BigDecimal getPrice() { return price; } @@ -147,6 +173,8 @@ public class OutRechargePrice implements Serializable { OutRechargePrice other = (OutRechargePrice) that; return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) && (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType())) + && (this.getShowType() == null ? other.getShowType() == null : this.getShowType().equals(other.getShowType())) + && (this.getCompanyId() == null ? other.getCompanyId() == null : this.getCompanyId().equals(other.getCompanyId())) && (this.getPrice() == null ? other.getPrice() == null : this.getPrice().equals(other.getPrice())) && (this.getRealPrice() == null ? other.getRealPrice() == null : this.getRealPrice().equals(other.getRealPrice())) && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())) @@ -162,6 +190,8 @@ public class OutRechargePrice implements Serializable { int result = 1; result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); result = prime * result + ((getType() == null) ? 0 : getType().hashCode()); + result = prime * result + ((getShowType() == null) ? 0 : getShowType().hashCode()); + result = prime * result + ((getCompanyId() == null) ? 0 : getCompanyId().hashCode()); result = prime * result + ((getPrice() == null) ? 0 : getPrice().hashCode()); result = prime * result + ((getRealPrice() == null) ? 0 : getRealPrice().hashCode()); result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); @@ -180,6 +210,8 @@ public class OutRechargePrice implements Serializable { sb.append("Hash = ").append(hashCode()); sb.append(", id=").append(id); sb.append(", type=").append(type); + sb.append(", showType=").append(showType); + sb.append(", companyId=").append(companyId); sb.append(", price=").append(price); sb.append(", realPrice=").append(realPrice); sb.append(", createTime=").append(createTime); diff --git a/hai-service/src/main/java/com/hai/entity/OutRechargePriceExample.java b/hai-service/src/main/java/com/hai/entity/OutRechargePriceExample.java index 2193e872..7b4f9647 100644 --- a/hai-service/src/main/java/com/hai/entity/OutRechargePriceExample.java +++ b/hai-service/src/main/java/com/hai/entity/OutRechargePriceExample.java @@ -246,6 +246,126 @@ public class OutRechargePriceExample { return (Criteria) this; } + public Criteria andShowTypeIsNull() { + addCriterion("show_type is null"); + return (Criteria) this; + } + + public Criteria andShowTypeIsNotNull() { + addCriterion("show_type is not null"); + return (Criteria) this; + } + + public Criteria andShowTypeEqualTo(Integer value) { + addCriterion("show_type =", value, "showType"); + return (Criteria) this; + } + + public Criteria andShowTypeNotEqualTo(Integer value) { + addCriterion("show_type <>", value, "showType"); + return (Criteria) this; + } + + public Criteria andShowTypeGreaterThan(Integer value) { + addCriterion("show_type >", value, "showType"); + return (Criteria) this; + } + + public Criteria andShowTypeGreaterThanOrEqualTo(Integer value) { + addCriterion("show_type >=", value, "showType"); + return (Criteria) this; + } + + public Criteria andShowTypeLessThan(Integer value) { + addCriterion("show_type <", value, "showType"); + return (Criteria) this; + } + + public Criteria andShowTypeLessThanOrEqualTo(Integer value) { + addCriterion("show_type <=", value, "showType"); + return (Criteria) this; + } + + public Criteria andShowTypeIn(List values) { + addCriterion("show_type in", values, "showType"); + return (Criteria) this; + } + + public Criteria andShowTypeNotIn(List values) { + addCriterion("show_type not in", values, "showType"); + return (Criteria) this; + } + + public Criteria andShowTypeBetween(Integer value1, Integer value2) { + addCriterion("show_type between", value1, value2, "showType"); + return (Criteria) this; + } + + public Criteria andShowTypeNotBetween(Integer value1, Integer value2) { + addCriterion("show_type not between", value1, value2, "showType"); + return (Criteria) this; + } + + public Criteria andCompanyIdIsNull() { + addCriterion("company_id is null"); + return (Criteria) this; + } + + public Criteria andCompanyIdIsNotNull() { + addCriterion("company_id is not null"); + return (Criteria) this; + } + + public Criteria andCompanyIdEqualTo(Long value) { + addCriterion("company_id =", value, "companyId"); + return (Criteria) this; + } + + public Criteria andCompanyIdNotEqualTo(Long value) { + addCriterion("company_id <>", value, "companyId"); + return (Criteria) this; + } + + public Criteria andCompanyIdGreaterThan(Long value) { + addCriterion("company_id >", value, "companyId"); + return (Criteria) this; + } + + public Criteria andCompanyIdGreaterThanOrEqualTo(Long value) { + addCriterion("company_id >=", value, "companyId"); + return (Criteria) this; + } + + public Criteria andCompanyIdLessThan(Long value) { + addCriterion("company_id <", value, "companyId"); + return (Criteria) this; + } + + public Criteria andCompanyIdLessThanOrEqualTo(Long value) { + addCriterion("company_id <=", value, "companyId"); + return (Criteria) this; + } + + public Criteria andCompanyIdIn(List values) { + addCriterion("company_id in", values, "companyId"); + return (Criteria) this; + } + + public Criteria andCompanyIdNotIn(List values) { + addCriterion("company_id not in", values, "companyId"); + return (Criteria) this; + } + + public Criteria andCompanyIdBetween(Long value1, Long value2) { + addCriterion("company_id between", value1, value2, "companyId"); + return (Criteria) this; + } + + public Criteria andCompanyIdNotBetween(Long value1, Long value2) { + addCriterion("company_id not between", value1, value2, "companyId"); + return (Criteria) this; + } + public Criteria andPriceIsNull() { addCriterion("price is null"); return (Criteria) this; diff --git a/hai-service/src/main/java/com/hai/service/impl/OutRechargePriceServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/OutRechargePriceServiceImpl.java index 82d0d5f1..eb310bd5 100644 --- a/hai-service/src/main/java/com/hai/service/impl/OutRechargePriceServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/OutRechargePriceServiceImpl.java @@ -25,6 +25,13 @@ public class OutRechargePriceServiceImpl implements OutRechargePriceService { if (StringUtils.isNotBlank(map.get("type"))) { criteria.andTypeEqualTo(Integer.valueOf(map.get("type"))); } + if (StringUtils.isNotBlank(map.get("showType"))) { + criteria.andShowTypeEqualTo(Integer.valueOf(map.get("showType"))); + } + + if (StringUtils.isNotBlank(map.get("companyId"))) { + criteria.andCompanyIdEqualTo(Long.valueOf(map.get("companyId"))); + } example.setOrderByClause("type asc"); return outRechargePriceMapper.selectByExample(example); @@ -39,7 +46,9 @@ public class OutRechargePriceServiceImpl implements OutRechargePriceService { if (StringUtils.isNotBlank(map.get("type"))) { criteria.andTypeEqualTo(Integer.valueOf(map.get("type"))); } - + if (StringUtils.isNotBlank(map.get("companyId"))) { + criteria.andCompanyIdEqualTo(Long.valueOf(map.get("companyId"))); + } example.setOrderByClause("sort asc"); return outRechargePriceMapper.selectByExample(example); } From 42cfce170675aa9410eee3528fd3d2e5d19f6df6 Mon Sep 17 00:00:00 2001 From: zdx <1810554661@qq.com> Date: Fri, 24 Dec 2021 11:22:16 +0800 Subject: [PATCH 5/9] 1 --- .../java/com/hai/dao/HighUserEtcMapper.java | 122 +++ .../com/hai/dao/HighUserEtcMapperExt.java | 7 + .../com/hai/dao/HighUserEtcSqlProvider.java | 318 ++++++ .../main/java/com/hai/entity/HighUserEtc.java | 216 ++++ .../com/hai/entity/HighUserEtcExample.java | 953 ++++++++++++++++++ 5 files changed, 1616 insertions(+) create mode 100644 hai-service/src/main/java/com/hai/dao/HighUserEtcMapper.java create mode 100644 hai-service/src/main/java/com/hai/dao/HighUserEtcMapperExt.java create mode 100644 hai-service/src/main/java/com/hai/dao/HighUserEtcSqlProvider.java create mode 100644 hai-service/src/main/java/com/hai/entity/HighUserEtc.java create mode 100644 hai-service/src/main/java/com/hai/entity/HighUserEtcExample.java diff --git a/hai-service/src/main/java/com/hai/dao/HighUserEtcMapper.java b/hai-service/src/main/java/com/hai/dao/HighUserEtcMapper.java new file mode 100644 index 00000000..12e535ca --- /dev/null +++ b/hai-service/src/main/java/com/hai/dao/HighUserEtcMapper.java @@ -0,0 +1,122 @@ +package com.hai.dao; + +import com.hai.entity.HighUserEtc; +import com.hai.entity.HighUserEtcExample; +import java.util.List; +import org.apache.ibatis.annotations.Delete; +import org.apache.ibatis.annotations.DeleteProvider; +import org.apache.ibatis.annotations.Insert; +import org.apache.ibatis.annotations.InsertProvider; +import org.apache.ibatis.annotations.Options; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Result; +import org.apache.ibatis.annotations.Results; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.SelectProvider; +import org.apache.ibatis.annotations.Update; +import org.apache.ibatis.annotations.UpdateProvider; +import org.apache.ibatis.type.JdbcType; +import org.springframework.stereotype.Repository; + +/** + * + * 代码由工具生成,请勿修改!!! + * 如果需要扩展请在其父类进行扩展 + * + **/ +@Repository +public interface HighUserEtcMapper extends HighUserEtcMapperExt { + @SelectProvider(type=HighUserEtcSqlProvider.class, method="countByExample") + long countByExample(HighUserEtcExample example); + + @DeleteProvider(type=HighUserEtcSqlProvider.class, method="deleteByExample") + int deleteByExample(HighUserEtcExample example); + + @Delete({ + "delete from high_user_etc", + "where id = #{id,jdbcType=INTEGER}" + }) + int deleteByPrimaryKey(Integer id); + + @Insert({ + "insert into high_user_etc (user_id, vehicle_id, ", + "vehicle_plate, customer_name, ", + "customer_tel, create_time, ", + "`status`, ext_1, ext_2, ", + "ext_3)", + "values (#{userId,jdbcType=BIGINT}, #{vehicleId,jdbcType=VARCHAR}, ", + "#{vehiclePlate,jdbcType=VARCHAR}, #{customerName,jdbcType=VARCHAR}, ", + "#{customerTel,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, ", + "#{status,jdbcType=INTEGER}, #{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, ", + "#{ext3,jdbcType=VARCHAR})" + }) + @Options(useGeneratedKeys=true,keyProperty="id") + int insert(HighUserEtc record); + + @InsertProvider(type=HighUserEtcSqlProvider.class, method="insertSelective") + @Options(useGeneratedKeys=true,keyProperty="id") + int insertSelective(HighUserEtc record); + + @SelectProvider(type=HighUserEtcSqlProvider.class, method="selectByExample") + @Results({ + @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true), + @Result(column="user_id", property="userId", jdbcType=JdbcType.BIGINT), + @Result(column="vehicle_id", property="vehicleId", jdbcType=JdbcType.VARCHAR), + @Result(column="vehicle_plate", property="vehiclePlate", jdbcType=JdbcType.VARCHAR), + @Result(column="customer_name", property="customerName", jdbcType=JdbcType.VARCHAR), + @Result(column="customer_tel", property="customerTel", jdbcType=JdbcType.VARCHAR), + @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="status", property="status", jdbcType=JdbcType.INTEGER), + @Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR), + @Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR), + @Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR) + }) + List selectByExample(HighUserEtcExample example); + + @Select({ + "select", + "id, user_id, vehicle_id, vehicle_plate, customer_name, customer_tel, create_time, ", + "`status`, ext_1, ext_2, ext_3", + "from high_user_etc", + "where id = #{id,jdbcType=INTEGER}" + }) + @Results({ + @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true), + @Result(column="user_id", property="userId", jdbcType=JdbcType.BIGINT), + @Result(column="vehicle_id", property="vehicleId", jdbcType=JdbcType.VARCHAR), + @Result(column="vehicle_plate", property="vehiclePlate", jdbcType=JdbcType.VARCHAR), + @Result(column="customer_name", property="customerName", jdbcType=JdbcType.VARCHAR), + @Result(column="customer_tel", property="customerTel", jdbcType=JdbcType.VARCHAR), + @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="status", property="status", jdbcType=JdbcType.INTEGER), + @Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR), + @Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR), + @Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR) + }) + HighUserEtc selectByPrimaryKey(Integer id); + + @UpdateProvider(type=HighUserEtcSqlProvider.class, method="updateByExampleSelective") + int updateByExampleSelective(@Param("record") HighUserEtc record, @Param("example") HighUserEtcExample example); + + @UpdateProvider(type=HighUserEtcSqlProvider.class, method="updateByExample") + int updateByExample(@Param("record") HighUserEtc record, @Param("example") HighUserEtcExample example); + + @UpdateProvider(type=HighUserEtcSqlProvider.class, method="updateByPrimaryKeySelective") + int updateByPrimaryKeySelective(HighUserEtc record); + + @Update({ + "update high_user_etc", + "set user_id = #{userId,jdbcType=BIGINT},", + "vehicle_id = #{vehicleId,jdbcType=VARCHAR},", + "vehicle_plate = #{vehiclePlate,jdbcType=VARCHAR},", + "customer_name = #{customerName,jdbcType=VARCHAR},", + "customer_tel = #{customerTel,jdbcType=VARCHAR},", + "create_time = #{createTime,jdbcType=TIMESTAMP},", + "`status` = #{status,jdbcType=INTEGER},", + "ext_1 = #{ext1,jdbcType=VARCHAR},", + "ext_2 = #{ext2,jdbcType=VARCHAR},", + "ext_3 = #{ext3,jdbcType=VARCHAR}", + "where id = #{id,jdbcType=INTEGER}" + }) + int updateByPrimaryKey(HighUserEtc record); +} \ No newline at end of file diff --git a/hai-service/src/main/java/com/hai/dao/HighUserEtcMapperExt.java b/hai-service/src/main/java/com/hai/dao/HighUserEtcMapperExt.java new file mode 100644 index 00000000..eca10d6f --- /dev/null +++ b/hai-service/src/main/java/com/hai/dao/HighUserEtcMapperExt.java @@ -0,0 +1,7 @@ +package com.hai.dao; + +/** + * mapper扩展类 + */ +public interface HighUserEtcMapperExt { +} \ No newline at end of file diff --git a/hai-service/src/main/java/com/hai/dao/HighUserEtcSqlProvider.java b/hai-service/src/main/java/com/hai/dao/HighUserEtcSqlProvider.java new file mode 100644 index 00000000..bc59d510 --- /dev/null +++ b/hai-service/src/main/java/com/hai/dao/HighUserEtcSqlProvider.java @@ -0,0 +1,318 @@ +package com.hai.dao; + +import com.hai.entity.HighUserEtc; +import com.hai.entity.HighUserEtcExample.Criteria; +import com.hai.entity.HighUserEtcExample.Criterion; +import com.hai.entity.HighUserEtcExample; +import java.util.List; +import java.util.Map; +import org.apache.ibatis.jdbc.SQL; + +public class HighUserEtcSqlProvider { + + public String countByExample(HighUserEtcExample example) { + SQL sql = new SQL(); + sql.SELECT("count(*)").FROM("high_user_etc"); + applyWhere(sql, example, false); + return sql.toString(); + } + + public String deleteByExample(HighUserEtcExample example) { + SQL sql = new SQL(); + sql.DELETE_FROM("high_user_etc"); + applyWhere(sql, example, false); + return sql.toString(); + } + + public String insertSelective(HighUserEtc record) { + SQL sql = new SQL(); + sql.INSERT_INTO("high_user_etc"); + + if (record.getUserId() != null) { + sql.VALUES("user_id", "#{userId,jdbcType=BIGINT}"); + } + + if (record.getVehicleId() != null) { + sql.VALUES("vehicle_id", "#{vehicleId,jdbcType=VARCHAR}"); + } + + if (record.getVehiclePlate() != null) { + sql.VALUES("vehicle_plate", "#{vehiclePlate,jdbcType=VARCHAR}"); + } + + if (record.getCustomerName() != null) { + sql.VALUES("customer_name", "#{customerName,jdbcType=VARCHAR}"); + } + + if (record.getCustomerTel() != null) { + sql.VALUES("customer_tel", "#{customerTel,jdbcType=VARCHAR}"); + } + + if (record.getCreateTime() != null) { + sql.VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}"); + } + + if (record.getStatus() != null) { + sql.VALUES("`status`", "#{status,jdbcType=INTEGER}"); + } + + if (record.getExt1() != null) { + sql.VALUES("ext_1", "#{ext1,jdbcType=VARCHAR}"); + } + + if (record.getExt2() != null) { + sql.VALUES("ext_2", "#{ext2,jdbcType=VARCHAR}"); + } + + if (record.getExt3() != null) { + sql.VALUES("ext_3", "#{ext3,jdbcType=VARCHAR}"); + } + + return sql.toString(); + } + + public String selectByExample(HighUserEtcExample example) { + SQL sql = new SQL(); + if (example != null && example.isDistinct()) { + sql.SELECT_DISTINCT("id"); + } else { + sql.SELECT("id"); + } + sql.SELECT("user_id"); + sql.SELECT("vehicle_id"); + sql.SELECT("vehicle_plate"); + sql.SELECT("customer_name"); + sql.SELECT("customer_tel"); + sql.SELECT("create_time"); + sql.SELECT("`status`"); + sql.SELECT("ext_1"); + sql.SELECT("ext_2"); + sql.SELECT("ext_3"); + sql.FROM("high_user_etc"); + applyWhere(sql, example, false); + + if (example != null && example.getOrderByClause() != null) { + sql.ORDER_BY(example.getOrderByClause()); + } + + return sql.toString(); + } + + public String updateByExampleSelective(Map parameter) { + HighUserEtc record = (HighUserEtc) parameter.get("record"); + HighUserEtcExample example = (HighUserEtcExample) parameter.get("example"); + + SQL sql = new SQL(); + sql.UPDATE("high_user_etc"); + + if (record.getId() != null) { + sql.SET("id = #{record.id,jdbcType=INTEGER}"); + } + + if (record.getUserId() != null) { + sql.SET("user_id = #{record.userId,jdbcType=BIGINT}"); + } + + if (record.getVehicleId() != null) { + sql.SET("vehicle_id = #{record.vehicleId,jdbcType=VARCHAR}"); + } + + if (record.getVehiclePlate() != null) { + sql.SET("vehicle_plate = #{record.vehiclePlate,jdbcType=VARCHAR}"); + } + + if (record.getCustomerName() != null) { + sql.SET("customer_name = #{record.customerName,jdbcType=VARCHAR}"); + } + + if (record.getCustomerTel() != null) { + sql.SET("customer_tel = #{record.customerTel,jdbcType=VARCHAR}"); + } + + if (record.getCreateTime() != null) { + sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); + } + + if (record.getStatus() != null) { + sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); + } + + if (record.getExt1() != null) { + sql.SET("ext_1 = #{record.ext1,jdbcType=VARCHAR}"); + } + + if (record.getExt2() != null) { + sql.SET("ext_2 = #{record.ext2,jdbcType=VARCHAR}"); + } + + if (record.getExt3() != null) { + sql.SET("ext_3 = #{record.ext3,jdbcType=VARCHAR}"); + } + + applyWhere(sql, example, true); + return sql.toString(); + } + + public String updateByExample(Map parameter) { + SQL sql = new SQL(); + sql.UPDATE("high_user_etc"); + + sql.SET("id = #{record.id,jdbcType=INTEGER}"); + sql.SET("user_id = #{record.userId,jdbcType=BIGINT}"); + sql.SET("vehicle_id = #{record.vehicleId,jdbcType=VARCHAR}"); + sql.SET("vehicle_plate = #{record.vehiclePlate,jdbcType=VARCHAR}"); + sql.SET("customer_name = #{record.customerName,jdbcType=VARCHAR}"); + sql.SET("customer_tel = #{record.customerTel,jdbcType=VARCHAR}"); + sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); + sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); + sql.SET("ext_1 = #{record.ext1,jdbcType=VARCHAR}"); + sql.SET("ext_2 = #{record.ext2,jdbcType=VARCHAR}"); + sql.SET("ext_3 = #{record.ext3,jdbcType=VARCHAR}"); + + HighUserEtcExample example = (HighUserEtcExample) parameter.get("example"); + applyWhere(sql, example, true); + return sql.toString(); + } + + public String updateByPrimaryKeySelective(HighUserEtc record) { + SQL sql = new SQL(); + sql.UPDATE("high_user_etc"); + + if (record.getUserId() != null) { + sql.SET("user_id = #{userId,jdbcType=BIGINT}"); + } + + if (record.getVehicleId() != null) { + sql.SET("vehicle_id = #{vehicleId,jdbcType=VARCHAR}"); + } + + if (record.getVehiclePlate() != null) { + sql.SET("vehicle_plate = #{vehiclePlate,jdbcType=VARCHAR}"); + } + + if (record.getCustomerName() != null) { + sql.SET("customer_name = #{customerName,jdbcType=VARCHAR}"); + } + + if (record.getCustomerTel() != null) { + sql.SET("customer_tel = #{customerTel,jdbcType=VARCHAR}"); + } + + if (record.getCreateTime() != null) { + sql.SET("create_time = #{createTime,jdbcType=TIMESTAMP}"); + } + + if (record.getStatus() != null) { + sql.SET("`status` = #{status,jdbcType=INTEGER}"); + } + + if (record.getExt1() != null) { + sql.SET("ext_1 = #{ext1,jdbcType=VARCHAR}"); + } + + if (record.getExt2() != null) { + sql.SET("ext_2 = #{ext2,jdbcType=VARCHAR}"); + } + + if (record.getExt3() != null) { + sql.SET("ext_3 = #{ext3,jdbcType=VARCHAR}"); + } + + sql.WHERE("id = #{id,jdbcType=INTEGER}"); + + return sql.toString(); + } + + protected void applyWhere(SQL sql, HighUserEtcExample example, boolean includeExamplePhrase) { + if (example == null) { + return; + } + + String parmPhrase1; + String parmPhrase1_th; + String parmPhrase2; + String parmPhrase2_th; + String parmPhrase3; + String parmPhrase3_th; + if (includeExamplePhrase) { + parmPhrase1 = "%s #{example.oredCriteria[%d].allCriteria[%d].value}"; + parmPhrase1_th = "%s #{example.oredCriteria[%d].allCriteria[%d].value,typeHandler=%s}"; + parmPhrase2 = "%s #{example.oredCriteria[%d].allCriteria[%d].value} and #{example.oredCriteria[%d].criteria[%d].secondValue}"; + parmPhrase2_th = "%s #{example.oredCriteria[%d].allCriteria[%d].value,typeHandler=%s} and #{example.oredCriteria[%d].criteria[%d].secondValue,typeHandler=%s}"; + parmPhrase3 = "#{example.oredCriteria[%d].allCriteria[%d].value[%d]}"; + parmPhrase3_th = "#{example.oredCriteria[%d].allCriteria[%d].value[%d],typeHandler=%s}"; + } else { + parmPhrase1 = "%s #{oredCriteria[%d].allCriteria[%d].value}"; + parmPhrase1_th = "%s #{oredCriteria[%d].allCriteria[%d].value,typeHandler=%s}"; + parmPhrase2 = "%s #{oredCriteria[%d].allCriteria[%d].value} and #{oredCriteria[%d].criteria[%d].secondValue}"; + parmPhrase2_th = "%s #{oredCriteria[%d].allCriteria[%d].value,typeHandler=%s} and #{oredCriteria[%d].criteria[%d].secondValue,typeHandler=%s}"; + parmPhrase3 = "#{oredCriteria[%d].allCriteria[%d].value[%d]}"; + parmPhrase3_th = "#{oredCriteria[%d].allCriteria[%d].value[%d],typeHandler=%s}"; + } + + StringBuilder sb = new StringBuilder(); + List oredCriteria = example.getOredCriteria(); + boolean firstCriteria = true; + for (int i = 0; i < oredCriteria.size(); i++) { + Criteria criteria = oredCriteria.get(i); + if (criteria.isValid()) { + if (firstCriteria) { + firstCriteria = false; + } else { + sb.append(" or "); + } + + sb.append('('); + List criterions = criteria.getAllCriteria(); + boolean firstCriterion = true; + for (int j = 0; j < criterions.size(); j++) { + Criterion criterion = criterions.get(j); + if (firstCriterion) { + firstCriterion = false; + } else { + sb.append(" and "); + } + + if (criterion.isNoValue()) { + sb.append(criterion.getCondition()); + } else if (criterion.isSingleValue()) { + if (criterion.getTypeHandler() == null) { + sb.append(String.format(parmPhrase1, criterion.getCondition(), i, j)); + } else { + sb.append(String.format(parmPhrase1_th, criterion.getCondition(), i, j,criterion.getTypeHandler())); + } + } else if (criterion.isBetweenValue()) { + if (criterion.getTypeHandler() == null) { + sb.append(String.format(parmPhrase2, criterion.getCondition(), i, j, i, j)); + } else { + sb.append(String.format(parmPhrase2_th, criterion.getCondition(), i, j, criterion.getTypeHandler(), i, j, criterion.getTypeHandler())); + } + } else if (criterion.isListValue()) { + sb.append(criterion.getCondition()); + sb.append(" ("); + List listItems = (List) criterion.getValue(); + boolean comma = false; + for (int k = 0; k < listItems.size(); k++) { + if (comma) { + sb.append(", "); + } else { + comma = true; + } + if (criterion.getTypeHandler() == null) { + sb.append(String.format(parmPhrase3, i, j, k)); + } else { + sb.append(String.format(parmPhrase3_th, i, j, k, criterion.getTypeHandler())); + } + } + sb.append(')'); + } + } + sb.append(')'); + } + } + + if (sb.length() > 0) { + sql.WHERE(sb.toString()); + } + } +} \ No newline at end of file diff --git a/hai-service/src/main/java/com/hai/entity/HighUserEtc.java b/hai-service/src/main/java/com/hai/entity/HighUserEtc.java new file mode 100644 index 00000000..3bb84908 --- /dev/null +++ b/hai-service/src/main/java/com/hai/entity/HighUserEtc.java @@ -0,0 +1,216 @@ +package com.hai.entity; + +import java.io.Serializable; +import java.util.Date; + +/** + * high_user_etc + * @author + */ +/** + * + * 代码由工具生成 + * + **/ +public class HighUserEtc implements Serializable { + /** + * 主键 + */ + private Integer id; + + /** + * 用户id + */ + private Long userId; + + /** + * 车辆id + */ + private String vehicleId; + + /** + * 车牌号 + */ + private String vehiclePlate; + + /** + * 用户名称 + */ + private String customerName; + + /** + * 用户电话 + */ + private String customerTel; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 状态 1:正常 0删除 + */ + private Integer status; + + private String ext1; + + private String ext2; + + private String ext3; + + private static final long serialVersionUID = 1L; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Long getUserId() { + return userId; + } + + public void setUserId(Long userId) { + this.userId = userId; + } + + public String getVehicleId() { + return vehicleId; + } + + public void setVehicleId(String vehicleId) { + this.vehicleId = vehicleId; + } + + public String getVehiclePlate() { + return vehiclePlate; + } + + public void setVehiclePlate(String vehiclePlate) { + this.vehiclePlate = vehiclePlate; + } + + public String getCustomerName() { + return customerName; + } + + public void setCustomerName(String customerName) { + this.customerName = customerName; + } + + public String getCustomerTel() { + return customerTel; + } + + public void setCustomerTel(String customerTel) { + this.customerTel = customerTel; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + public String getExt1() { + return ext1; + } + + public void setExt1(String ext1) { + this.ext1 = ext1; + } + + public String getExt2() { + return ext2; + } + + public void setExt2(String ext2) { + this.ext2 = ext2; + } + + public String getExt3() { + return ext3; + } + + public void setExt3(String ext3) { + this.ext3 = ext3; + } + + @Override + public boolean equals(Object that) { + if (this == that) { + return true; + } + if (that == null) { + return false; + } + if (getClass() != that.getClass()) { + return false; + } + HighUserEtc other = (HighUserEtc) that; + return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) + && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId())) + && (this.getVehicleId() == null ? other.getVehicleId() == null : this.getVehicleId().equals(other.getVehicleId())) + && (this.getVehiclePlate() == null ? other.getVehiclePlate() == null : this.getVehiclePlate().equals(other.getVehiclePlate())) + && (this.getCustomerName() == null ? other.getCustomerName() == null : this.getCustomerName().equals(other.getCustomerName())) + && (this.getCustomerTel() == null ? other.getCustomerTel() == null : this.getCustomerTel().equals(other.getCustomerTel())) + && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())) + && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus())) + && (this.getExt1() == null ? other.getExt1() == null : this.getExt1().equals(other.getExt1())) + && (this.getExt2() == null ? other.getExt2() == null : this.getExt2().equals(other.getExt2())) + && (this.getExt3() == null ? other.getExt3() == null : this.getExt3().equals(other.getExt3())); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); + result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode()); + result = prime * result + ((getVehicleId() == null) ? 0 : getVehicleId().hashCode()); + result = prime * result + ((getVehiclePlate() == null) ? 0 : getVehiclePlate().hashCode()); + result = prime * result + ((getCustomerName() == null) ? 0 : getCustomerName().hashCode()); + result = prime * result + ((getCustomerTel() == null) ? 0 : getCustomerTel().hashCode()); + result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); + result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode()); + result = prime * result + ((getExt1() == null) ? 0 : getExt1().hashCode()); + result = prime * result + ((getExt2() == null) ? 0 : getExt2().hashCode()); + result = prime * result + ((getExt3() == null) ? 0 : getExt3().hashCode()); + return result; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(getClass().getSimpleName()); + sb.append(" ["); + sb.append("Hash = ").append(hashCode()); + sb.append(", id=").append(id); + sb.append(", userId=").append(userId); + sb.append(", vehicleId=").append(vehicleId); + sb.append(", vehiclePlate=").append(vehiclePlate); + sb.append(", customerName=").append(customerName); + sb.append(", customerTel=").append(customerTel); + sb.append(", createTime=").append(createTime); + sb.append(", status=").append(status); + sb.append(", ext1=").append(ext1); + sb.append(", ext2=").append(ext2); + sb.append(", ext3=").append(ext3); + sb.append(", serialVersionUID=").append(serialVersionUID); + sb.append("]"); + return sb.toString(); + } +} \ No newline at end of file diff --git a/hai-service/src/main/java/com/hai/entity/HighUserEtcExample.java b/hai-service/src/main/java/com/hai/entity/HighUserEtcExample.java new file mode 100644 index 00000000..3498e767 --- /dev/null +++ b/hai-service/src/main/java/com/hai/entity/HighUserEtcExample.java @@ -0,0 +1,953 @@ +package com.hai.entity; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +public class HighUserEtcExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + private Integer limit; + + private Long offset; + + public HighUserEtcExample() { + oredCriteria = new ArrayList(); + } + + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + public String getOrderByClause() { + return orderByClause; + } + + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + public boolean isDistinct() { + return distinct; + } + + public List getOredCriteria() { + return oredCriteria; + } + + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + public Criteria or() { + Criteria criteria = createCriteriaInternal(); + oredCriteria.add(criteria); + return criteria; + } + + public Criteria createCriteria() { + Criteria criteria = createCriteriaInternal(); + if (oredCriteria.size() == 0) { + oredCriteria.add(criteria); + } + return criteria; + } + + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + public void setLimit(Integer limit) { + this.limit = limit; + } + + public Integer getLimit() { + return limit; + } + + public void setOffset(Long offset) { + this.offset = offset; + } + + public Long getOffset() { + return offset; + } + + protected abstract static class GeneratedCriteria { + protected List criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List getCriteria() { + return criteria; + } + + protected void addCriterion(String condition) { + if (condition == null) { + throw new RuntimeException("Value for condition cannot be null"); + } + criteria.add(new Criterion(condition)); + } + + protected void addCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value)); + } + + protected void addCriterion(String condition, Object value1, Object value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value1, value2)); + } + + public Criteria andIdIsNull() { + addCriterion("id is null"); + return (Criteria) this; + } + + public Criteria andIdIsNotNull() { + addCriterion("id is not null"); + return (Criteria) this; + } + + public Criteria andIdEqualTo(Integer value) { + addCriterion("id =", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotEqualTo(Integer value) { + addCriterion("id <>", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThan(Integer value) { + addCriterion("id >", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThanOrEqualTo(Integer value) { + addCriterion("id >=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThan(Integer value) { + addCriterion("id <", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThanOrEqualTo(Integer value) { + addCriterion("id <=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdIn(List values) { + addCriterion("id in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdNotIn(List values) { + addCriterion("id not in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdBetween(Integer value1, Integer value2) { + addCriterion("id between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andIdNotBetween(Integer value1, Integer value2) { + addCriterion("id not between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andUserIdIsNull() { + addCriterion("user_id is null"); + return (Criteria) this; + } + + public Criteria andUserIdIsNotNull() { + addCriterion("user_id is not null"); + return (Criteria) this; + } + + public Criteria andUserIdEqualTo(Long value) { + addCriterion("user_id =", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotEqualTo(Long value) { + addCriterion("user_id <>", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdGreaterThan(Long value) { + addCriterion("user_id >", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdGreaterThanOrEqualTo(Long value) { + addCriterion("user_id >=", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdLessThan(Long value) { + addCriterion("user_id <", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdLessThanOrEqualTo(Long value) { + addCriterion("user_id <=", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdIn(List values) { + addCriterion("user_id in", values, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotIn(List values) { + addCriterion("user_id not in", values, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdBetween(Long value1, Long value2) { + addCriterion("user_id between", value1, value2, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotBetween(Long value1, Long value2) { + addCriterion("user_id not between", value1, value2, "userId"); + return (Criteria) this; + } + + public Criteria andVehicleIdIsNull() { + addCriterion("vehicle_id is null"); + return (Criteria) this; + } + + public Criteria andVehicleIdIsNotNull() { + addCriterion("vehicle_id is not null"); + return (Criteria) this; + } + + public Criteria andVehicleIdEqualTo(String value) { + addCriterion("vehicle_id =", value, "vehicleId"); + return (Criteria) this; + } + + public Criteria andVehicleIdNotEqualTo(String value) { + addCriterion("vehicle_id <>", value, "vehicleId"); + return (Criteria) this; + } + + public Criteria andVehicleIdGreaterThan(String value) { + addCriterion("vehicle_id >", value, "vehicleId"); + return (Criteria) this; + } + + public Criteria andVehicleIdGreaterThanOrEqualTo(String value) { + addCriterion("vehicle_id >=", value, "vehicleId"); + return (Criteria) this; + } + + public Criteria andVehicleIdLessThan(String value) { + addCriterion("vehicle_id <", value, "vehicleId"); + return (Criteria) this; + } + + public Criteria andVehicleIdLessThanOrEqualTo(String value) { + addCriterion("vehicle_id <=", value, "vehicleId"); + return (Criteria) this; + } + + public Criteria andVehicleIdLike(String value) { + addCriterion("vehicle_id like", value, "vehicleId"); + return (Criteria) this; + } + + public Criteria andVehicleIdNotLike(String value) { + addCriterion("vehicle_id not like", value, "vehicleId"); + return (Criteria) this; + } + + public Criteria andVehicleIdIn(List values) { + addCriterion("vehicle_id in", values, "vehicleId"); + return (Criteria) this; + } + + public Criteria andVehicleIdNotIn(List values) { + addCriterion("vehicle_id not in", values, "vehicleId"); + return (Criteria) this; + } + + public Criteria andVehicleIdBetween(String value1, String value2) { + addCriterion("vehicle_id between", value1, value2, "vehicleId"); + return (Criteria) this; + } + + public Criteria andVehicleIdNotBetween(String value1, String value2) { + addCriterion("vehicle_id not between", value1, value2, "vehicleId"); + return (Criteria) this; + } + + public Criteria andVehiclePlateIsNull() { + addCriterion("vehicle_plate is null"); + return (Criteria) this; + } + + public Criteria andVehiclePlateIsNotNull() { + addCriterion("vehicle_plate is not null"); + return (Criteria) this; + } + + public Criteria andVehiclePlateEqualTo(String value) { + addCriterion("vehicle_plate =", value, "vehiclePlate"); + return (Criteria) this; + } + + public Criteria andVehiclePlateNotEqualTo(String value) { + addCriterion("vehicle_plate <>", value, "vehiclePlate"); + return (Criteria) this; + } + + public Criteria andVehiclePlateGreaterThan(String value) { + addCriterion("vehicle_plate >", value, "vehiclePlate"); + return (Criteria) this; + } + + public Criteria andVehiclePlateGreaterThanOrEqualTo(String value) { + addCriterion("vehicle_plate >=", value, "vehiclePlate"); + return (Criteria) this; + } + + public Criteria andVehiclePlateLessThan(String value) { + addCriterion("vehicle_plate <", value, "vehiclePlate"); + return (Criteria) this; + } + + public Criteria andVehiclePlateLessThanOrEqualTo(String value) { + addCriterion("vehicle_plate <=", value, "vehiclePlate"); + return (Criteria) this; + } + + public Criteria andVehiclePlateLike(String value) { + addCriterion("vehicle_plate like", value, "vehiclePlate"); + return (Criteria) this; + } + + public Criteria andVehiclePlateNotLike(String value) { + addCriterion("vehicle_plate not like", value, "vehiclePlate"); + return (Criteria) this; + } + + public Criteria andVehiclePlateIn(List values) { + addCriterion("vehicle_plate in", values, "vehiclePlate"); + return (Criteria) this; + } + + public Criteria andVehiclePlateNotIn(List values) { + addCriterion("vehicle_plate not in", values, "vehiclePlate"); + return (Criteria) this; + } + + public Criteria andVehiclePlateBetween(String value1, String value2) { + addCriterion("vehicle_plate between", value1, value2, "vehiclePlate"); + return (Criteria) this; + } + + public Criteria andVehiclePlateNotBetween(String value1, String value2) { + addCriterion("vehicle_plate not between", value1, value2, "vehiclePlate"); + return (Criteria) this; + } + + public Criteria andCustomerNameIsNull() { + addCriterion("customer_name is null"); + return (Criteria) this; + } + + public Criteria andCustomerNameIsNotNull() { + addCriterion("customer_name is not null"); + return (Criteria) this; + } + + public Criteria andCustomerNameEqualTo(String value) { + addCriterion("customer_name =", value, "customerName"); + return (Criteria) this; + } + + public Criteria andCustomerNameNotEqualTo(String value) { + addCriterion("customer_name <>", value, "customerName"); + return (Criteria) this; + } + + public Criteria andCustomerNameGreaterThan(String value) { + addCriterion("customer_name >", value, "customerName"); + return (Criteria) this; + } + + public Criteria andCustomerNameGreaterThanOrEqualTo(String value) { + addCriterion("customer_name >=", value, "customerName"); + return (Criteria) this; + } + + public Criteria andCustomerNameLessThan(String value) { + addCriterion("customer_name <", value, "customerName"); + return (Criteria) this; + } + + public Criteria andCustomerNameLessThanOrEqualTo(String value) { + addCriterion("customer_name <=", value, "customerName"); + return (Criteria) this; + } + + public Criteria andCustomerNameLike(String value) { + addCriterion("customer_name like", value, "customerName"); + return (Criteria) this; + } + + public Criteria andCustomerNameNotLike(String value) { + addCriterion("customer_name not like", value, "customerName"); + return (Criteria) this; + } + + public Criteria andCustomerNameIn(List values) { + addCriterion("customer_name in", values, "customerName"); + return (Criteria) this; + } + + public Criteria andCustomerNameNotIn(List values) { + addCriterion("customer_name not in", values, "customerName"); + return (Criteria) this; + } + + public Criteria andCustomerNameBetween(String value1, String value2) { + addCriterion("customer_name between", value1, value2, "customerName"); + return (Criteria) this; + } + + public Criteria andCustomerNameNotBetween(String value1, String value2) { + addCriterion("customer_name not between", value1, value2, "customerName"); + return (Criteria) this; + } + + public Criteria andCustomerTelIsNull() { + addCriterion("customer_tel is null"); + return (Criteria) this; + } + + public Criteria andCustomerTelIsNotNull() { + addCriterion("customer_tel is not null"); + return (Criteria) this; + } + + public Criteria andCustomerTelEqualTo(String value) { + addCriterion("customer_tel =", value, "customerTel"); + return (Criteria) this; + } + + public Criteria andCustomerTelNotEqualTo(String value) { + addCriterion("customer_tel <>", value, "customerTel"); + return (Criteria) this; + } + + public Criteria andCustomerTelGreaterThan(String value) { + addCriterion("customer_tel >", value, "customerTel"); + return (Criteria) this; + } + + public Criteria andCustomerTelGreaterThanOrEqualTo(String value) { + addCriterion("customer_tel >=", value, "customerTel"); + return (Criteria) this; + } + + public Criteria andCustomerTelLessThan(String value) { + addCriterion("customer_tel <", value, "customerTel"); + return (Criteria) this; + } + + public Criteria andCustomerTelLessThanOrEqualTo(String value) { + addCriterion("customer_tel <=", value, "customerTel"); + return (Criteria) this; + } + + public Criteria andCustomerTelLike(String value) { + addCriterion("customer_tel like", value, "customerTel"); + return (Criteria) this; + } + + public Criteria andCustomerTelNotLike(String value) { + addCriterion("customer_tel not like", value, "customerTel"); + return (Criteria) this; + } + + public Criteria andCustomerTelIn(List values) { + addCriterion("customer_tel in", values, "customerTel"); + return (Criteria) this; + } + + public Criteria andCustomerTelNotIn(List values) { + addCriterion("customer_tel not in", values, "customerTel"); + return (Criteria) this; + } + + public Criteria andCustomerTelBetween(String value1, String value2) { + addCriterion("customer_tel between", value1, value2, "customerTel"); + return (Criteria) this; + } + + public Criteria andCustomerTelNotBetween(String value1, String value2) { + addCriterion("customer_tel not between", value1, value2, "customerTel"); + return (Criteria) this; + } + + public Criteria andCreateTimeIsNull() { + addCriterion("create_time is null"); + return (Criteria) this; + } + + public Criteria andCreateTimeIsNotNull() { + addCriterion("create_time is not null"); + return (Criteria) this; + } + + public Criteria andCreateTimeEqualTo(Date value) { + addCriterion("create_time =", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotEqualTo(Date value) { + addCriterion("create_time <>", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeGreaterThan(Date value) { + addCriterion("create_time >", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) { + addCriterion("create_time >=", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeLessThan(Date value) { + addCriterion("create_time <", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeLessThanOrEqualTo(Date value) { + addCriterion("create_time <=", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeIn(List values) { + addCriterion("create_time in", values, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotIn(List values) { + addCriterion("create_time not in", values, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeBetween(Date value1, Date value2) { + addCriterion("create_time between", value1, value2, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotBetween(Date value1, Date value2) { + addCriterion("create_time not between", value1, value2, "createTime"); + return (Criteria) this; + } + + public Criteria andStatusIsNull() { + addCriterion("`status` is null"); + return (Criteria) this; + } + + public Criteria andStatusIsNotNull() { + addCriterion("`status` is not null"); + return (Criteria) this; + } + + public Criteria andStatusEqualTo(Integer value) { + addCriterion("`status` =", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusNotEqualTo(Integer value) { + addCriterion("`status` <>", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusGreaterThan(Integer value) { + addCriterion("`status` >", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusGreaterThanOrEqualTo(Integer value) { + addCriterion("`status` >=", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusLessThan(Integer value) { + addCriterion("`status` <", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusLessThanOrEqualTo(Integer value) { + addCriterion("`status` <=", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusIn(List values) { + addCriterion("`status` in", values, "status"); + return (Criteria) this; + } + + public Criteria andStatusNotIn(List values) { + addCriterion("`status` not in", values, "status"); + return (Criteria) this; + } + + public Criteria andStatusBetween(Integer value1, Integer value2) { + addCriterion("`status` between", value1, value2, "status"); + return (Criteria) this; + } + + public Criteria andStatusNotBetween(Integer value1, Integer value2) { + addCriterion("`status` not between", value1, value2, "status"); + return (Criteria) this; + } + + public Criteria andExt1IsNull() { + addCriterion("ext_1 is null"); + return (Criteria) this; + } + + public Criteria andExt1IsNotNull() { + addCriterion("ext_1 is not null"); + return (Criteria) this; + } + + public Criteria andExt1EqualTo(String value) { + addCriterion("ext_1 =", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1NotEqualTo(String value) { + addCriterion("ext_1 <>", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1GreaterThan(String value) { + addCriterion("ext_1 >", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1GreaterThanOrEqualTo(String value) { + addCriterion("ext_1 >=", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1LessThan(String value) { + addCriterion("ext_1 <", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1LessThanOrEqualTo(String value) { + addCriterion("ext_1 <=", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1Like(String value) { + addCriterion("ext_1 like", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1NotLike(String value) { + addCriterion("ext_1 not like", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1In(List values) { + addCriterion("ext_1 in", values, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1NotIn(List values) { + addCriterion("ext_1 not in", values, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1Between(String value1, String value2) { + addCriterion("ext_1 between", value1, value2, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1NotBetween(String value1, String value2) { + addCriterion("ext_1 not between", value1, value2, "ext1"); + return (Criteria) this; + } + + public Criteria andExt2IsNull() { + addCriterion("ext_2 is null"); + return (Criteria) this; + } + + public Criteria andExt2IsNotNull() { + addCriterion("ext_2 is not null"); + return (Criteria) this; + } + + public Criteria andExt2EqualTo(String value) { + addCriterion("ext_2 =", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2NotEqualTo(String value) { + addCriterion("ext_2 <>", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2GreaterThan(String value) { + addCriterion("ext_2 >", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2GreaterThanOrEqualTo(String value) { + addCriterion("ext_2 >=", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2LessThan(String value) { + addCriterion("ext_2 <", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2LessThanOrEqualTo(String value) { + addCriterion("ext_2 <=", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2Like(String value) { + addCriterion("ext_2 like", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2NotLike(String value) { + addCriterion("ext_2 not like", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2In(List values) { + addCriterion("ext_2 in", values, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2NotIn(List values) { + addCriterion("ext_2 not in", values, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2Between(String value1, String value2) { + addCriterion("ext_2 between", value1, value2, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2NotBetween(String value1, String value2) { + addCriterion("ext_2 not between", value1, value2, "ext2"); + return (Criteria) this; + } + + public Criteria andExt3IsNull() { + addCriterion("ext_3 is null"); + return (Criteria) this; + } + + public Criteria andExt3IsNotNull() { + addCriterion("ext_3 is not null"); + return (Criteria) this; + } + + public Criteria andExt3EqualTo(String value) { + addCriterion("ext_3 =", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3NotEqualTo(String value) { + addCriterion("ext_3 <>", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3GreaterThan(String value) { + addCriterion("ext_3 >", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3GreaterThanOrEqualTo(String value) { + addCriterion("ext_3 >=", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3LessThan(String value) { + addCriterion("ext_3 <", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3LessThanOrEqualTo(String value) { + addCriterion("ext_3 <=", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3Like(String value) { + addCriterion("ext_3 like", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3NotLike(String value) { + addCriterion("ext_3 not like", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3In(List values) { + addCriterion("ext_3 in", values, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3NotIn(List values) { + addCriterion("ext_3 not in", values, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3Between(String value1, String value2) { + addCriterion("ext_3 between", value1, value2, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3NotBetween(String value1, String value2) { + addCriterion("ext_3 not between", value1, value2, "ext3"); + return (Criteria) this; + } + } + + /** + */ + public static class Criteria extends GeneratedCriteria { + + protected Criteria() { + super(); + } + } + + public static class Criterion { + private String condition; + + private Object value; + + private Object secondValue; + + private boolean noValue; + + private boolean singleValue; + + private boolean betweenValue; + + private boolean listValue; + + private String typeHandler; + + public String getCondition() { + return condition; + } + + public Object getValue() { + return value; + } + + public Object getSecondValue() { + return secondValue; + } + + public boolean isNoValue() { + return noValue; + } + + public boolean isSingleValue() { + return singleValue; + } + + public boolean isBetweenValue() { + return betweenValue; + } + + public boolean isListValue() { + return listValue; + } + + public String getTypeHandler() { + return typeHandler; + } + + protected Criterion(String condition) { + super(); + this.condition = condition; + this.typeHandler = null; + this.noValue = true; + } + + protected Criterion(String condition, Object value, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.typeHandler = typeHandler; + if (value instanceof List) { + this.listValue = true; + } else { + this.singleValue = true; + } + } + + protected Criterion(String condition, Object value) { + this(condition, value, null); + } + + protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.secondValue = secondValue; + this.typeHandler = typeHandler; + this.betweenValue = true; + } + + protected Criterion(String condition, Object value, Object secondValue) { + this(condition, value, secondValue, null); + } + } +} \ No newline at end of file From 42d1582a051ee553552800ea1e15fc19ac8551a5 Mon Sep 17 00:00:00 2001 From: Sum1Dream <418471657@qq.com> Date: Fri, 24 Dec 2021 11:24:56 +0800 Subject: [PATCH 6/9] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/cweb/controller/HighOrderController.java | 2 +- .../com/cweb/controller/OutRechargePriceController.java | 8 ++++++-- .../com/hai/service/impl/OutRechargePriceServiceImpl.java | 3 +++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java b/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java index 76b425c3..045078c5 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java @@ -346,7 +346,7 @@ public class HighOrderController { // 卡卷类型 1:满减 2:抵扣 3:折扣 if (highDiscountUserRel.getHighDiscount().getDiscountType() == 3) { // 折扣除100 - BigDecimal discountPrice = highDiscountUserRel.getHighDiscount().getDiscountPrice().divide(new BigDecimal("10")); + BigDecimal discountPrice = highDiscountUserRel.getHighDiscount().getDiscountPrice(); // 订单总额 * 折扣 BigDecimal payPrice = highOrder.getTotalPrice().multiply(discountPrice); highOrder.setDeductionPrice(highOrder.getTotalPrice().subtract(payPrice)); diff --git a/hai-cweb/src/main/java/com/cweb/controller/OutRechargePriceController.java b/hai-cweb/src/main/java/com/cweb/controller/OutRechargePriceController.java index 90cc8087..9e5a8ed6 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/OutRechargePriceController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/OutRechargePriceController.java @@ -59,7 +59,8 @@ public class OutRechargePriceController { @ApiOperation(value = "查询充值金额列表") public ResponseData getListOutRechargePrice( @RequestParam(value = "type", required = false) Integer type, - @RequestParam(name = "regionId", required = true) String regionId + @RequestParam(name = "regionId", required = true) String regionId, + @RequestParam(name = "showType", required = true) Integer showType ) { try { Map map = new HashMap<>(); @@ -71,8 +72,11 @@ public class OutRechargePriceController { } if (type != null ) { - map.put("type", String.valueOf(type)); + map.put("showType", String.valueOf(showType)); + } + if (type != null ) { + map.put("type", String.valueOf(type)); } return ResponseMsgUtil.success( outRechargePriceService.getListRechargePriceC(map)); diff --git a/hai-service/src/main/java/com/hai/service/impl/OutRechargePriceServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/OutRechargePriceServiceImpl.java index eb310bd5..5392cc6b 100644 --- a/hai-service/src/main/java/com/hai/service/impl/OutRechargePriceServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/OutRechargePriceServiceImpl.java @@ -46,6 +46,9 @@ public class OutRechargePriceServiceImpl implements OutRechargePriceService { if (StringUtils.isNotBlank(map.get("type"))) { criteria.andTypeEqualTo(Integer.valueOf(map.get("type"))); } + if (StringUtils.isNotBlank(map.get("showType"))) { + criteria.andShowTypeEqualTo(Integer.valueOf(map.get("showType"))); + } if (StringUtils.isNotBlank(map.get("companyId"))) { criteria.andCompanyIdEqualTo(Long.valueOf(map.get("companyId"))); } From bcde92c9e20adb3d02c2561739888783df7881e0 Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Mon, 3 Jan 2022 09:57:43 +0800 Subject: [PATCH 7/9] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=85=91=E6=8D=A2?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/HighCouponAgentController.java | 8 +- .../bweb/controller/HighCouponController.java | 4 +- .../main/java/com/cweb/config/AuthConfig.java | 1 + .../controller/HighCouponAgentController.java | 77 ++++++ .../{generateCode.java => GenerateCode.java} | 25 +- .../hai/dao/HighCouponAgentCodeMapper.java | 34 ++- .../dao/HighCouponAgentCodeSqlProvider.java | 56 +++-- .../com/hai/dao/HighCouponAgentRelMapper.java | 33 +-- .../hai/dao/HighCouponAgentRelMapperExt.java | 4 +- .../dao/HighCouponAgentRelSqlProvider.java | 14 ++ .../com/hai/entity/HighCouponAgentCode.java | 62 +++-- .../entity/HighCouponAgentCodeExample.java | 226 ++++++++++++++---- .../com/hai/entity/HighCouponAgentRel.java | 16 ++ .../hai/entity/HighCouponAgentRelExample.java | 60 +++++ .../hai/service/HighCouponAgentService.java | 25 +- .../impl/HighCouponAgentServiceImpl.java | 151 +++++++++--- 16 files changed, 646 insertions(+), 150 deletions(-) create mode 100644 hai-cweb/src/main/java/com/cweb/controller/HighCouponAgentController.java rename hai-service/src/main/java/com/hai/common/{generateCode.java => GenerateCode.java} (56%) diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighCouponAgentController.java b/hai-bweb/src/main/java/com/bweb/controller/HighCouponAgentController.java index fb7a13de..94d9f79f 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighCouponAgentController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighCouponAgentController.java @@ -61,7 +61,8 @@ public class HighCouponAgentController { @RequestMapping(value = "/getAgentCount", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "代理商统计") - public ResponseData getAgentCount(HttpServletRequest request) { + public ResponseData getAgentCount(HttpServletRequest request, + @RequestParam(name = "type", required = true) Integer type) { try { SessionObject sessionObject = userCenter.getSessionObject(request); UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); @@ -71,7 +72,7 @@ public class HighCouponAgentController { throw ErrorHelp.genException(SysCode.System, ErrorCode.MENU_TREE_HAS_NOT_ERROR, ""); } - return ResponseMsgUtil.success(highCouponAgentService.getSalesCountByAgent(userInfoModel.getHighAgent().getId())); + return ResponseMsgUtil.success(highCouponAgentService.getSalesCountByAgent(userInfoModel.getHighAgent().getId(), type)); } catch (Exception e) { log.error("HighCouponAgentController --> getCodeById() error!", e); @@ -187,6 +188,7 @@ public class HighCouponAgentController { if(highCouponAgentRel.getCouponId() == null || highCouponAgentRel.getAgentId() == null + || highCouponAgentRel.getType() == null || highCouponAgentRel.getStockCount() == null) { log.error("HighCouponAgentController -> assignCouponAgent() error!","参数错误"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); @@ -207,7 +209,7 @@ public class HighCouponAgentController { } // 校验是否分配过 - HighCouponAgentRel couponAgent = highCouponAgentService.getRelByCouponAgent(highCouponAgentRel.getCouponId(), highCouponAgentRel.getAgentId()); + HighCouponAgentRel couponAgent = highCouponAgentService.getRelByCouponAgent(highCouponAgentRel.getCouponId(), highCouponAgentRel.getAgentId(), highCouponAgentRel.getType()); if (couponAgent != null) { couponAgent.setStockCount(couponAgent.getStockCount() + highCouponAgentRel.getStockCount()); couponAgent.setOperatorId(userInfoModel.getSecUser().getId()); diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java b/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java index e8bd2408..0b55d2ff 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java @@ -12,7 +12,7 @@ import com.github.pagehelper.PageInfo; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; -import com.hai.common.generateCode; +import com.hai.common.GenerateCode; import com.hai.common.security.SessionObject; import com.hai.common.security.UserCenter; import com.hai.common.utils.DateUtil; @@ -620,7 +620,7 @@ public class HighCouponController { highCouponCode = new HighCouponCode(); highCouponCode.setCouponId(couponId); highCouponCode.setMerchantId(coupon.getMerchantId()); - highCouponCode.setSalesCode(generateCode.couponSalesCode(coupon.getMerchantId(), couponId)); + highCouponCode.setSalesCode(GenerateCode.couponSalesCode(coupon.getMerchantId(), couponId)); highCouponCode.setSalesEndTime(salesEndTimeC.getTime()); highCouponCode.setUseEndTime(useEndTimeC.getTime()); highCouponCode.setStatus(1); // 状态:1.待销售 2.未使用 3.已使用 99.预支付 diff --git a/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java b/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java index c119e8c6..f6276a3e 100644 --- a/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java +++ b/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java @@ -93,6 +93,7 @@ public class AuthConfig implements WebMvcConfigurer { .excludePathPatterns("/order/*") .excludePathPatterns("/coupon/getCouponList") .excludePathPatterns("/wechatpay/*") + .excludePathPatterns("/couponAgent/useConvertCode") .excludePathPatterns("/coupon/getCouponById") .excludePathPatterns("/discount/getDiscountByQrCode") .excludePathPatterns("/discount/getDiscountById") diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighCouponAgentController.java b/hai-cweb/src/main/java/com/cweb/controller/HighCouponAgentController.java new file mode 100644 index 00000000..099a751a --- /dev/null +++ b/hai-cweb/src/main/java/com/cweb/controller/HighCouponAgentController.java @@ -0,0 +1,77 @@ +package com.cweb.controller; + +import com.alibaba.fastjson.JSONObject; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.hai.common.exception.ErrorCode; +import com.hai.common.exception.ErrorHelp; +import com.hai.common.exception.SysCode; +import com.hai.common.security.SessionObject; +import com.hai.common.security.UserCenter; +import com.hai.common.utils.DateUtil; +import com.hai.common.utils.ResponseMsgUtil; +import com.hai.entity.*; +import com.hai.model.ResponseData; +import com.hai.model.UserInfoModel; +import com.hai.service.*; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.math.BigDecimal; +import java.util.*; + +/** + * @Auther: 胡锐 + * @Description: + * @Date: 2021/4/20 23:47 + */ +@Controller +@RequestMapping(value = "/couponAgent") +@Api(value = "代理商接口") +public class HighCouponAgentController { + + private static Logger log = LoggerFactory.getLogger(HighCouponAgentController.class); + + @Resource + private HighCouponAgentService highCouponAgentService; + + @RequestMapping(value = "/useConvertCode", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "兑换码使用") + public ResponseData useConvertCode(@RequestBody JSONObject body) { + try { + + if (body == null || StringUtils.isBlank(body.getString("code"))) { + log.error("HighCouponAgentController -> queryConvertCode() error!",""); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + // 查询兑换码 + HighCouponAgentCode convertCode = highCouponAgentService.getConvertCode(body.getString("code")); + if (convertCode == null) { + log.error("HighCouponAgentController -> queryConvertCode() error!","无效的兑换码"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无效的兑换码"); + } + if (convertCode.getStatus() != 1) { + log.error("HighCouponAgentController -> queryConvertCode() error!","兑换码已被使用"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "兑换码已被使用"); + } + + return ResponseMsgUtil.success(highCouponAgentService.useConvertCode(body.getString("code"))); + + } catch (Exception e) { + log.error("HighCouponAgentController --> useConvertCode() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + +} diff --git a/hai-service/src/main/java/com/hai/common/generateCode.java b/hai-service/src/main/java/com/hai/common/GenerateCode.java similarity index 56% rename from hai-service/src/main/java/com/hai/common/generateCode.java rename to hai-service/src/main/java/com/hai/common/GenerateCode.java index aa6d1c27..ac87b81d 100644 --- a/hai-service/src/main/java/com/hai/common/generateCode.java +++ b/hai-service/src/main/java/com/hai/common/GenerateCode.java @@ -1,5 +1,6 @@ package com.hai.common; +import java.security.SecureRandom; import java.util.Calendar; import java.util.Random; @@ -8,8 +9,11 @@ import java.util.Random; * @Description: * @Date: 2021/3/18 21:07 */ -public class generateCode { +public class GenerateCode { + private static final Random RANDOM = new SecureRandom(); + + private static final String SYMBOLS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; /** * @Author 胡锐 @@ -33,4 +37,23 @@ public class generateCode { } return val; } + + /** + * 生成兑换码 + * @param couponAgentRelId + * @return + */ + public static String convertCode(Long couponAgentRelId) { + // 兑换码总长度 + int countLength = 20; + // 需要生成的长度 + int generateLength = countLength - couponAgentRelId.toString().length(); + + char[] nonceChars = new char[generateLength]; + for (int index = 0; index < nonceChars.length; ++index) { + nonceChars[index] = SYMBOLS.charAt(RANDOM.nextInt(SYMBOLS.length())); + } + return new String(nonceChars) + couponAgentRelId; + } + } diff --git a/hai-service/src/main/java/com/hai/dao/HighCouponAgentCodeMapper.java b/hai-service/src/main/java/com/hai/dao/HighCouponAgentCodeMapper.java index f876a552..92cb7f29 100644 --- a/hai-service/src/main/java/com/hai/dao/HighCouponAgentCodeMapper.java +++ b/hai-service/src/main/java/com/hai/dao/HighCouponAgentCodeMapper.java @@ -39,16 +39,18 @@ public interface HighCouponAgentCodeMapper extends HighCouponAgentCodeMapperExt int deleteByPrimaryKey(Long id); @Insert({ - "insert into high_coupon_agent_code (coupon_agent_id, coupon_id, ", - "agent_id, coupon_code_id, ", - "coupon_agent_record_id, coupon_code, ", + "insert into high_coupon_agent_code (`type`, coupon_agent_id, ", + "coupon_id, agent_id, ", + "coupon_agent_record_id, convert_code, ", + "coupon_code_id, coupon_code, ", "qr_code, `status`, ", "remark, create_time, ", "operator_id, operator_name, ", "ext_1, ext_2, ext_3)", - "values (#{couponAgentId,jdbcType=BIGINT}, #{couponId,jdbcType=BIGINT}, ", - "#{agentId,jdbcType=BIGINT}, #{couponCodeId,jdbcType=BIGINT}, ", - "#{couponAgentRecordId,jdbcType=BIGINT}, #{couponCode,jdbcType=VARCHAR}, ", + "values (#{type,jdbcType=INTEGER}, #{couponAgentId,jdbcType=BIGINT}, ", + "#{couponId,jdbcType=BIGINT}, #{agentId,jdbcType=BIGINT}, ", + "#{couponAgentRecordId,jdbcType=BIGINT}, #{convertCode,jdbcType=VARCHAR}, ", + "#{couponCodeId,jdbcType=BIGINT}, #{couponCode,jdbcType=VARCHAR}, ", "#{qrCode,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, ", "#{remark,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, ", "#{operatorId,jdbcType=BIGINT}, #{operatorName,jdbcType=VARCHAR}, ", @@ -64,11 +66,13 @@ public interface HighCouponAgentCodeMapper extends HighCouponAgentCodeMapperExt @SelectProvider(type=HighCouponAgentCodeSqlProvider.class, method="selectByExample") @Results({ @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), + @Result(column="type", property="type", jdbcType=JdbcType.INTEGER), @Result(column="coupon_agent_id", property="couponAgentId", jdbcType=JdbcType.BIGINT), @Result(column="coupon_id", property="couponId", jdbcType=JdbcType.BIGINT), @Result(column="agent_id", property="agentId", jdbcType=JdbcType.BIGINT), - @Result(column="coupon_code_id", property="couponCodeId", jdbcType=JdbcType.BIGINT), @Result(column="coupon_agent_record_id", property="couponAgentRecordId", jdbcType=JdbcType.BIGINT), + @Result(column="convert_code", property="convertCode", jdbcType=JdbcType.VARCHAR), + @Result(column="coupon_code_id", property="couponCodeId", jdbcType=JdbcType.BIGINT), @Result(column="coupon_code", property="couponCode", jdbcType=JdbcType.VARCHAR), @Result(column="qr_code", property="qrCode", jdbcType=JdbcType.VARCHAR), @Result(column="status", property="status", jdbcType=JdbcType.INTEGER), @@ -84,19 +88,21 @@ public interface HighCouponAgentCodeMapper extends HighCouponAgentCodeMapperExt @Select({ "select", - "id, coupon_agent_id, coupon_id, agent_id, coupon_code_id, coupon_agent_record_id, ", - "coupon_code, qr_code, `status`, remark, create_time, operator_id, operator_name, ", - "ext_1, ext_2, ext_3", + "id, `type`, coupon_agent_id, coupon_id, agent_id, coupon_agent_record_id, convert_code, ", + "coupon_code_id, coupon_code, qr_code, `status`, remark, create_time, operator_id, ", + "operator_name, ext_1, ext_2, ext_3", "from high_coupon_agent_code", "where id = #{id,jdbcType=BIGINT}" }) @Results({ @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), + @Result(column="type", property="type", jdbcType=JdbcType.INTEGER), @Result(column="coupon_agent_id", property="couponAgentId", jdbcType=JdbcType.BIGINT), @Result(column="coupon_id", property="couponId", jdbcType=JdbcType.BIGINT), @Result(column="agent_id", property="agentId", jdbcType=JdbcType.BIGINT), - @Result(column="coupon_code_id", property="couponCodeId", jdbcType=JdbcType.BIGINT), @Result(column="coupon_agent_record_id", property="couponAgentRecordId", jdbcType=JdbcType.BIGINT), + @Result(column="convert_code", property="convertCode", jdbcType=JdbcType.VARCHAR), + @Result(column="coupon_code_id", property="couponCodeId", jdbcType=JdbcType.BIGINT), @Result(column="coupon_code", property="couponCode", jdbcType=JdbcType.VARCHAR), @Result(column="qr_code", property="qrCode", jdbcType=JdbcType.VARCHAR), @Result(column="status", property="status", jdbcType=JdbcType.INTEGER), @@ -121,11 +127,13 @@ public interface HighCouponAgentCodeMapper extends HighCouponAgentCodeMapperExt @Update({ "update high_coupon_agent_code", - "set coupon_agent_id = #{couponAgentId,jdbcType=BIGINT},", + "set `type` = #{type,jdbcType=INTEGER},", + "coupon_agent_id = #{couponAgentId,jdbcType=BIGINT},", "coupon_id = #{couponId,jdbcType=BIGINT},", "agent_id = #{agentId,jdbcType=BIGINT},", - "coupon_code_id = #{couponCodeId,jdbcType=BIGINT},", "coupon_agent_record_id = #{couponAgentRecordId,jdbcType=BIGINT},", + "convert_code = #{convertCode,jdbcType=VARCHAR},", + "coupon_code_id = #{couponCodeId,jdbcType=BIGINT},", "coupon_code = #{couponCode,jdbcType=VARCHAR},", "qr_code = #{qrCode,jdbcType=VARCHAR},", "`status` = #{status,jdbcType=INTEGER},", diff --git a/hai-service/src/main/java/com/hai/dao/HighCouponAgentCodeSqlProvider.java b/hai-service/src/main/java/com/hai/dao/HighCouponAgentCodeSqlProvider.java index 3ff4fd78..50f71478 100644 --- a/hai-service/src/main/java/com/hai/dao/HighCouponAgentCodeSqlProvider.java +++ b/hai-service/src/main/java/com/hai/dao/HighCouponAgentCodeSqlProvider.java @@ -28,6 +28,10 @@ public class HighCouponAgentCodeSqlProvider { SQL sql = new SQL(); sql.INSERT_INTO("high_coupon_agent_code"); + if (record.getType() != null) { + sql.VALUES("`type`", "#{type,jdbcType=INTEGER}"); + } + if (record.getCouponAgentId() != null) { sql.VALUES("coupon_agent_id", "#{couponAgentId,jdbcType=BIGINT}"); } @@ -40,14 +44,18 @@ public class HighCouponAgentCodeSqlProvider { sql.VALUES("agent_id", "#{agentId,jdbcType=BIGINT}"); } - if (record.getCouponCodeId() != null) { - sql.VALUES("coupon_code_id", "#{couponCodeId,jdbcType=BIGINT}"); - } - if (record.getCouponAgentRecordId() != null) { sql.VALUES("coupon_agent_record_id", "#{couponAgentRecordId,jdbcType=BIGINT}"); } + if (record.getConvertCode() != null) { + sql.VALUES("convert_code", "#{convertCode,jdbcType=VARCHAR}"); + } + + if (record.getCouponCodeId() != null) { + sql.VALUES("coupon_code_id", "#{couponCodeId,jdbcType=BIGINT}"); + } + if (record.getCouponCode() != null) { sql.VALUES("coupon_code", "#{couponCode,jdbcType=VARCHAR}"); } @@ -98,11 +106,13 @@ public class HighCouponAgentCodeSqlProvider { } else { sql.SELECT("id"); } + sql.SELECT("`type`"); sql.SELECT("coupon_agent_id"); sql.SELECT("coupon_id"); sql.SELECT("agent_id"); - sql.SELECT("coupon_code_id"); sql.SELECT("coupon_agent_record_id"); + sql.SELECT("convert_code"); + sql.SELECT("coupon_code_id"); sql.SELECT("coupon_code"); sql.SELECT("qr_code"); sql.SELECT("`status`"); @@ -134,6 +144,10 @@ public class HighCouponAgentCodeSqlProvider { sql.SET("id = #{record.id,jdbcType=BIGINT}"); } + if (record.getType() != null) { + sql.SET("`type` = #{record.type,jdbcType=INTEGER}"); + } + if (record.getCouponAgentId() != null) { sql.SET("coupon_agent_id = #{record.couponAgentId,jdbcType=BIGINT}"); } @@ -146,14 +160,18 @@ public class HighCouponAgentCodeSqlProvider { sql.SET("agent_id = #{record.agentId,jdbcType=BIGINT}"); } - if (record.getCouponCodeId() != null) { - sql.SET("coupon_code_id = #{record.couponCodeId,jdbcType=BIGINT}"); - } - if (record.getCouponAgentRecordId() != null) { sql.SET("coupon_agent_record_id = #{record.couponAgentRecordId,jdbcType=BIGINT}"); } + if (record.getConvertCode() != null) { + sql.SET("convert_code = #{record.convertCode,jdbcType=VARCHAR}"); + } + + if (record.getCouponCodeId() != null) { + sql.SET("coupon_code_id = #{record.couponCodeId,jdbcType=BIGINT}"); + } + if (record.getCouponCode() != null) { sql.SET("coupon_code = #{record.couponCode,jdbcType=VARCHAR}"); } @@ -203,11 +221,13 @@ public class HighCouponAgentCodeSqlProvider { sql.UPDATE("high_coupon_agent_code"); sql.SET("id = #{record.id,jdbcType=BIGINT}"); + sql.SET("`type` = #{record.type,jdbcType=INTEGER}"); sql.SET("coupon_agent_id = #{record.couponAgentId,jdbcType=BIGINT}"); sql.SET("coupon_id = #{record.couponId,jdbcType=BIGINT}"); sql.SET("agent_id = #{record.agentId,jdbcType=BIGINT}"); - sql.SET("coupon_code_id = #{record.couponCodeId,jdbcType=BIGINT}"); sql.SET("coupon_agent_record_id = #{record.couponAgentRecordId,jdbcType=BIGINT}"); + sql.SET("convert_code = #{record.convertCode,jdbcType=VARCHAR}"); + sql.SET("coupon_code_id = #{record.couponCodeId,jdbcType=BIGINT}"); sql.SET("coupon_code = #{record.couponCode,jdbcType=VARCHAR}"); sql.SET("qr_code = #{record.qrCode,jdbcType=VARCHAR}"); sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); @@ -228,6 +248,10 @@ public class HighCouponAgentCodeSqlProvider { SQL sql = new SQL(); sql.UPDATE("high_coupon_agent_code"); + if (record.getType() != null) { + sql.SET("`type` = #{type,jdbcType=INTEGER}"); + } + if (record.getCouponAgentId() != null) { sql.SET("coupon_agent_id = #{couponAgentId,jdbcType=BIGINT}"); } @@ -240,14 +264,18 @@ public class HighCouponAgentCodeSqlProvider { sql.SET("agent_id = #{agentId,jdbcType=BIGINT}"); } - if (record.getCouponCodeId() != null) { - sql.SET("coupon_code_id = #{couponCodeId,jdbcType=BIGINT}"); - } - if (record.getCouponAgentRecordId() != null) { sql.SET("coupon_agent_record_id = #{couponAgentRecordId,jdbcType=BIGINT}"); } + if (record.getConvertCode() != null) { + sql.SET("convert_code = #{convertCode,jdbcType=VARCHAR}"); + } + + if (record.getCouponCodeId() != null) { + sql.SET("coupon_code_id = #{couponCodeId,jdbcType=BIGINT}"); + } + if (record.getCouponCode() != null) { sql.SET("coupon_code = #{couponCode,jdbcType=VARCHAR}"); } diff --git a/hai-service/src/main/java/com/hai/dao/HighCouponAgentRelMapper.java b/hai-service/src/main/java/com/hai/dao/HighCouponAgentRelMapper.java index a166f0ee..3cf1e4e3 100644 --- a/hai-service/src/main/java/com/hai/dao/HighCouponAgentRelMapper.java +++ b/hai-service/src/main/java/com/hai/dao/HighCouponAgentRelMapper.java @@ -39,18 +39,20 @@ public interface HighCouponAgentRelMapper extends HighCouponAgentRelMapperExt { int deleteByPrimaryKey(Long id); @Insert({ - "insert into high_coupon_agent_rel (coupon_name, sales_price, ", - "coupon_id, agent_id, ", - "stock_count, sales_count, ", - "create_time, `status`, ", - "operator_id, operator_name, ", - "ext_1, ext_2, ext_3)", - "values (#{couponName,jdbcType=VARCHAR}, #{salesPrice,jdbcType=DECIMAL}, ", - "#{couponId,jdbcType=BIGINT}, #{agentId,jdbcType=BIGINT}, ", - "#{stockCount,jdbcType=INTEGER}, #{salesCount,jdbcType=INTEGER}, ", - "#{createTime,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER}, ", - "#{operatorId,jdbcType=BIGINT}, #{operatorName,jdbcType=VARCHAR}, ", - "#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" + "insert into high_coupon_agent_rel (`type`, coupon_name, ", + "sales_price, coupon_id, ", + "agent_id, stock_count, ", + "sales_count, create_time, ", + "`status`, operator_id, ", + "operator_name, ext_1, ", + "ext_2, ext_3)", + "values (#{type,jdbcType=INTEGER}, #{couponName,jdbcType=VARCHAR}, ", + "#{salesPrice,jdbcType=DECIMAL}, #{couponId,jdbcType=BIGINT}, ", + "#{agentId,jdbcType=BIGINT}, #{stockCount,jdbcType=INTEGER}, ", + "#{salesCount,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, ", + "#{status,jdbcType=INTEGER}, #{operatorId,jdbcType=BIGINT}, ", + "#{operatorName,jdbcType=VARCHAR}, #{ext1,jdbcType=VARCHAR}, ", + "#{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" }) @Options(useGeneratedKeys=true,keyProperty="id") int insert(HighCouponAgentRel record); @@ -62,6 +64,7 @@ public interface HighCouponAgentRelMapper extends HighCouponAgentRelMapperExt { @SelectProvider(type=HighCouponAgentRelSqlProvider.class, method="selectByExample") @Results({ @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), + @Result(column="type", property="type", jdbcType=JdbcType.INTEGER), @Result(column="coupon_name", property="couponName", jdbcType=JdbcType.VARCHAR), @Result(column="sales_price", property="salesPrice", jdbcType=JdbcType.DECIMAL), @Result(column="coupon_id", property="couponId", jdbcType=JdbcType.BIGINT), @@ -80,13 +83,14 @@ public interface HighCouponAgentRelMapper extends HighCouponAgentRelMapperExt { @Select({ "select", - "id, coupon_name, sales_price, coupon_id, agent_id, stock_count, sales_count, ", + "id, `type`, coupon_name, sales_price, coupon_id, agent_id, stock_count, sales_count, ", "create_time, `status`, operator_id, operator_name, ext_1, ext_2, ext_3", "from high_coupon_agent_rel", "where id = #{id,jdbcType=BIGINT}" }) @Results({ @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), + @Result(column="type", property="type", jdbcType=JdbcType.INTEGER), @Result(column="coupon_name", property="couponName", jdbcType=JdbcType.VARCHAR), @Result(column="sales_price", property="salesPrice", jdbcType=JdbcType.DECIMAL), @Result(column="coupon_id", property="couponId", jdbcType=JdbcType.BIGINT), @@ -114,7 +118,8 @@ public interface HighCouponAgentRelMapper extends HighCouponAgentRelMapperExt { @Update({ "update high_coupon_agent_rel", - "set coupon_name = #{couponName,jdbcType=VARCHAR},", + "set `type` = #{type,jdbcType=INTEGER},", + "coupon_name = #{couponName,jdbcType=VARCHAR},", "sales_price = #{salesPrice,jdbcType=DECIMAL},", "coupon_id = #{couponId,jdbcType=BIGINT},", "agent_id = #{agentId,jdbcType=BIGINT},", diff --git a/hai-service/src/main/java/com/hai/dao/HighCouponAgentRelMapperExt.java b/hai-service/src/main/java/com/hai/dao/HighCouponAgentRelMapperExt.java index 818a82f5..fa7e3062 100644 --- a/hai-service/src/main/java/com/hai/dao/HighCouponAgentRelMapperExt.java +++ b/hai-service/src/main/java/com/hai/dao/HighCouponAgentRelMapperExt.java @@ -47,6 +47,6 @@ public interface HighCouponAgentRelMapperExt { }) List getAgentSalesCodeList(@Param("agentId") Long agentId, @Param("consumeTimeS")String consumeTimeS, @Param("consumeTimeE")String consumeTimeE); - @Select(" select count(1) from high_coupon_agent_code a where a.agent_id = #{agentId} and a.`status` in (#{status}) ") - Integer getAgentCodeCount(@Param("agentId") Long agentId,@Param("status") String status); + @Select(" select count(1) from high_coupon_agent_code a where a.agent_id = #{agentId} and a.`status` in (#{status}) and a.type = #{type} ") + Integer getAgentCodeCount(@Param("agentId") Long agentId,@Param("status") String status,@Param("type") Integer type); } diff --git a/hai-service/src/main/java/com/hai/dao/HighCouponAgentRelSqlProvider.java b/hai-service/src/main/java/com/hai/dao/HighCouponAgentRelSqlProvider.java index 7783432a..13d0d982 100644 --- a/hai-service/src/main/java/com/hai/dao/HighCouponAgentRelSqlProvider.java +++ b/hai-service/src/main/java/com/hai/dao/HighCouponAgentRelSqlProvider.java @@ -28,6 +28,10 @@ public class HighCouponAgentRelSqlProvider { SQL sql = new SQL(); sql.INSERT_INTO("high_coupon_agent_rel"); + if (record.getType() != null) { + sql.VALUES("`type`", "#{type,jdbcType=INTEGER}"); + } + if (record.getCouponName() != null) { sql.VALUES("coupon_name", "#{couponName,jdbcType=VARCHAR}"); } @@ -90,6 +94,7 @@ public class HighCouponAgentRelSqlProvider { } else { sql.SELECT("id"); } + sql.SELECT("`type`"); sql.SELECT("coupon_name"); sql.SELECT("sales_price"); sql.SELECT("coupon_id"); @@ -124,6 +129,10 @@ public class HighCouponAgentRelSqlProvider { sql.SET("id = #{record.id,jdbcType=BIGINT}"); } + if (record.getType() != null) { + sql.SET("`type` = #{record.type,jdbcType=INTEGER}"); + } + if (record.getCouponName() != null) { sql.SET("coupon_name = #{record.couponName,jdbcType=VARCHAR}"); } @@ -185,6 +194,7 @@ public class HighCouponAgentRelSqlProvider { sql.UPDATE("high_coupon_agent_rel"); sql.SET("id = #{record.id,jdbcType=BIGINT}"); + sql.SET("`type` = #{record.type,jdbcType=INTEGER}"); sql.SET("coupon_name = #{record.couponName,jdbcType=VARCHAR}"); sql.SET("sales_price = #{record.salesPrice,jdbcType=DECIMAL}"); sql.SET("coupon_id = #{record.couponId,jdbcType=BIGINT}"); @@ -208,6 +218,10 @@ public class HighCouponAgentRelSqlProvider { SQL sql = new SQL(); sql.UPDATE("high_coupon_agent_rel"); + if (record.getType() != null) { + sql.SET("`type` = #{type,jdbcType=INTEGER}"); + } + if (record.getCouponName() != null) { sql.SET("coupon_name = #{couponName,jdbcType=VARCHAR}"); } diff --git a/hai-service/src/main/java/com/hai/entity/HighCouponAgentCode.java b/hai-service/src/main/java/com/hai/entity/HighCouponAgentCode.java index 1fae72af..6b21861f 100644 --- a/hai-service/src/main/java/com/hai/entity/HighCouponAgentCode.java +++ b/hai-service/src/main/java/com/hai/entity/HighCouponAgentCode.java @@ -20,6 +20,11 @@ public class HighCouponAgentCode extends HighCouponAgentCodeModel implements Ser */ private Long id; + /** + * 类型 1:销售码 2:兑换码 + */ + private Integer type; + /** * 卡券和代理商的id */ @@ -36,14 +41,19 @@ public class HighCouponAgentCode extends HighCouponAgentCodeModel implements Ser private Long agentId; /** - * 销售码id + * 卡券分配给代理商库存记录id */ - private Long couponCodeId; + private Long couponAgentRecordId; /** - * 卡券分配给代理商库存记录id + * 兑换码 */ - private Long couponAgentRecordId; + private String convertCode; + + /** + * 销售码id + */ + private Long couponCodeId; /** * 销售码 @@ -96,6 +106,14 @@ public class HighCouponAgentCode extends HighCouponAgentCodeModel implements Ser this.id = id; } + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + public Long getCouponAgentId() { return couponAgentId; } @@ -120,14 +138,6 @@ public class HighCouponAgentCode extends HighCouponAgentCodeModel implements Ser this.agentId = agentId; } - public Long getCouponCodeId() { - return couponCodeId; - } - - public void setCouponCodeId(Long couponCodeId) { - this.couponCodeId = couponCodeId; - } - public Long getCouponAgentRecordId() { return couponAgentRecordId; } @@ -136,6 +146,22 @@ public class HighCouponAgentCode extends HighCouponAgentCodeModel implements Ser this.couponAgentRecordId = couponAgentRecordId; } + public String getConvertCode() { + return convertCode; + } + + public void setConvertCode(String convertCode) { + this.convertCode = convertCode; + } + + public Long getCouponCodeId() { + return couponCodeId; + } + + public void setCouponCodeId(Long couponCodeId) { + this.couponCodeId = couponCodeId; + } + public String getCouponCode() { return couponCode; } @@ -229,11 +255,13 @@ public class HighCouponAgentCode extends HighCouponAgentCodeModel implements Ser } HighCouponAgentCode other = (HighCouponAgentCode) that; return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) + && (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType())) && (this.getCouponAgentId() == null ? other.getCouponAgentId() == null : this.getCouponAgentId().equals(other.getCouponAgentId())) && (this.getCouponId() == null ? other.getCouponId() == null : this.getCouponId().equals(other.getCouponId())) && (this.getAgentId() == null ? other.getAgentId() == null : this.getAgentId().equals(other.getAgentId())) - && (this.getCouponCodeId() == null ? other.getCouponCodeId() == null : this.getCouponCodeId().equals(other.getCouponCodeId())) && (this.getCouponAgentRecordId() == null ? other.getCouponAgentRecordId() == null : this.getCouponAgentRecordId().equals(other.getCouponAgentRecordId())) + && (this.getConvertCode() == null ? other.getConvertCode() == null : this.getConvertCode().equals(other.getConvertCode())) + && (this.getCouponCodeId() == null ? other.getCouponCodeId() == null : this.getCouponCodeId().equals(other.getCouponCodeId())) && (this.getCouponCode() == null ? other.getCouponCode() == null : this.getCouponCode().equals(other.getCouponCode())) && (this.getQrCode() == null ? other.getQrCode() == null : this.getQrCode().equals(other.getQrCode())) && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus())) @@ -251,11 +279,13 @@ public class HighCouponAgentCode extends HighCouponAgentCodeModel implements Ser final int prime = 31; int result = 1; result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); + result = prime * result + ((getType() == null) ? 0 : getType().hashCode()); result = prime * result + ((getCouponAgentId() == null) ? 0 : getCouponAgentId().hashCode()); result = prime * result + ((getCouponId() == null) ? 0 : getCouponId().hashCode()); result = prime * result + ((getAgentId() == null) ? 0 : getAgentId().hashCode()); - result = prime * result + ((getCouponCodeId() == null) ? 0 : getCouponCodeId().hashCode()); result = prime * result + ((getCouponAgentRecordId() == null) ? 0 : getCouponAgentRecordId().hashCode()); + result = prime * result + ((getConvertCode() == null) ? 0 : getConvertCode().hashCode()); + result = prime * result + ((getCouponCodeId() == null) ? 0 : getCouponCodeId().hashCode()); result = prime * result + ((getCouponCode() == null) ? 0 : getCouponCode().hashCode()); result = prime * result + ((getQrCode() == null) ? 0 : getQrCode().hashCode()); result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode()); @@ -276,11 +306,13 @@ public class HighCouponAgentCode extends HighCouponAgentCodeModel implements Ser sb.append(" ["); sb.append("Hash = ").append(hashCode()); sb.append(", id=").append(id); + sb.append(", type=").append(type); sb.append(", couponAgentId=").append(couponAgentId); sb.append(", couponId=").append(couponId); sb.append(", agentId=").append(agentId); - sb.append(", couponCodeId=").append(couponCodeId); sb.append(", couponAgentRecordId=").append(couponAgentRecordId); + sb.append(", convertCode=").append(convertCode); + sb.append(", couponCodeId=").append(couponCodeId); sb.append(", couponCode=").append(couponCode); sb.append(", qrCode=").append(qrCode); sb.append(", status=").append(status); diff --git a/hai-service/src/main/java/com/hai/entity/HighCouponAgentCodeExample.java b/hai-service/src/main/java/com/hai/entity/HighCouponAgentCodeExample.java index fbd038f7..cccf62bb 100644 --- a/hai-service/src/main/java/com/hai/entity/HighCouponAgentCodeExample.java +++ b/hai-service/src/main/java/com/hai/entity/HighCouponAgentCodeExample.java @@ -185,6 +185,66 @@ public class HighCouponAgentCodeExample { return (Criteria) this; } + public Criteria andTypeIsNull() { + addCriterion("`type` is null"); + return (Criteria) this; + } + + public Criteria andTypeIsNotNull() { + addCriterion("`type` is not null"); + return (Criteria) this; + } + + public Criteria andTypeEqualTo(Integer value) { + addCriterion("`type` =", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeNotEqualTo(Integer value) { + addCriterion("`type` <>", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeGreaterThan(Integer value) { + addCriterion("`type` >", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeGreaterThanOrEqualTo(Integer value) { + addCriterion("`type` >=", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeLessThan(Integer value) { + addCriterion("`type` <", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeLessThanOrEqualTo(Integer value) { + addCriterion("`type` <=", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeIn(List values) { + addCriterion("`type` in", values, "type"); + return (Criteria) this; + } + + public Criteria andTypeNotIn(List values) { + addCriterion("`type` not in", values, "type"); + return (Criteria) this; + } + + public Criteria andTypeBetween(Integer value1, Integer value2) { + addCriterion("`type` between", value1, value2, "type"); + return (Criteria) this; + } + + public Criteria andTypeNotBetween(Integer value1, Integer value2) { + addCriterion("`type` not between", value1, value2, "type"); + return (Criteria) this; + } + public Criteria andCouponAgentIdIsNull() { addCriterion("coupon_agent_id is null"); return (Criteria) this; @@ -365,123 +425,193 @@ public class HighCouponAgentCodeExample { return (Criteria) this; } - public Criteria andCouponCodeIdIsNull() { - addCriterion("coupon_code_id is null"); + public Criteria andCouponAgentRecordIdIsNull() { + addCriterion("coupon_agent_record_id is null"); return (Criteria) this; } - public Criteria andCouponCodeIdIsNotNull() { - addCriterion("coupon_code_id is not null"); + public Criteria andCouponAgentRecordIdIsNotNull() { + addCriterion("coupon_agent_record_id is not null"); return (Criteria) this; } - public Criteria andCouponCodeIdEqualTo(Long value) { - addCriterion("coupon_code_id =", value, "couponCodeId"); + public Criteria andCouponAgentRecordIdEqualTo(Long value) { + addCriterion("coupon_agent_record_id =", value, "couponAgentRecordId"); return (Criteria) this; } - public Criteria andCouponCodeIdNotEqualTo(Long value) { - addCriterion("coupon_code_id <>", value, "couponCodeId"); + public Criteria andCouponAgentRecordIdNotEqualTo(Long value) { + addCriterion("coupon_agent_record_id <>", value, "couponAgentRecordId"); return (Criteria) this; } - public Criteria andCouponCodeIdGreaterThan(Long value) { - addCriterion("coupon_code_id >", value, "couponCodeId"); + public Criteria andCouponAgentRecordIdGreaterThan(Long value) { + addCriterion("coupon_agent_record_id >", value, "couponAgentRecordId"); return (Criteria) this; } - public Criteria andCouponCodeIdGreaterThanOrEqualTo(Long value) { - addCriterion("coupon_code_id >=", value, "couponCodeId"); + public Criteria andCouponAgentRecordIdGreaterThanOrEqualTo(Long value) { + addCriterion("coupon_agent_record_id >=", value, "couponAgentRecordId"); return (Criteria) this; } - public Criteria andCouponCodeIdLessThan(Long value) { - addCriterion("coupon_code_id <", value, "couponCodeId"); + public Criteria andCouponAgentRecordIdLessThan(Long value) { + addCriterion("coupon_agent_record_id <", value, "couponAgentRecordId"); return (Criteria) this; } - public Criteria andCouponCodeIdLessThanOrEqualTo(Long value) { - addCriterion("coupon_code_id <=", value, "couponCodeId"); + public Criteria andCouponAgentRecordIdLessThanOrEqualTo(Long value) { + addCriterion("coupon_agent_record_id <=", value, "couponAgentRecordId"); return (Criteria) this; } - public Criteria andCouponCodeIdIn(List values) { - addCriterion("coupon_code_id in", values, "couponCodeId"); + public Criteria andCouponAgentRecordIdIn(List values) { + addCriterion("coupon_agent_record_id in", values, "couponAgentRecordId"); return (Criteria) this; } - public Criteria andCouponCodeIdNotIn(List values) { - addCriterion("coupon_code_id not in", values, "couponCodeId"); + public Criteria andCouponAgentRecordIdNotIn(List values) { + addCriterion("coupon_agent_record_id not in", values, "couponAgentRecordId"); return (Criteria) this; } - public Criteria andCouponCodeIdBetween(Long value1, Long value2) { - addCriterion("coupon_code_id between", value1, value2, "couponCodeId"); + public Criteria andCouponAgentRecordIdBetween(Long value1, Long value2) { + addCriterion("coupon_agent_record_id between", value1, value2, "couponAgentRecordId"); return (Criteria) this; } - public Criteria andCouponCodeIdNotBetween(Long value1, Long value2) { - addCriterion("coupon_code_id not between", value1, value2, "couponCodeId"); + public Criteria andCouponAgentRecordIdNotBetween(Long value1, Long value2) { + addCriterion("coupon_agent_record_id not between", value1, value2, "couponAgentRecordId"); return (Criteria) this; } - public Criteria andCouponAgentRecordIdIsNull() { - addCriterion("coupon_agent_record_id is null"); + public Criteria andConvertCodeIsNull() { + addCriterion("convert_code is null"); return (Criteria) this; } - public Criteria andCouponAgentRecordIdIsNotNull() { - addCriterion("coupon_agent_record_id is not null"); + public Criteria andConvertCodeIsNotNull() { + addCriterion("convert_code is not null"); return (Criteria) this; } - public Criteria andCouponAgentRecordIdEqualTo(Long value) { - addCriterion("coupon_agent_record_id =", value, "couponAgentRecordId"); + public Criteria andConvertCodeEqualTo(String value) { + addCriterion("convert_code =", value, "convertCode"); return (Criteria) this; } - public Criteria andCouponAgentRecordIdNotEqualTo(Long value) { - addCriterion("coupon_agent_record_id <>", value, "couponAgentRecordId"); + public Criteria andConvertCodeNotEqualTo(String value) { + addCriterion("convert_code <>", value, "convertCode"); return (Criteria) this; } - public Criteria andCouponAgentRecordIdGreaterThan(Long value) { - addCriterion("coupon_agent_record_id >", value, "couponAgentRecordId"); + public Criteria andConvertCodeGreaterThan(String value) { + addCriterion("convert_code >", value, "convertCode"); return (Criteria) this; } - public Criteria andCouponAgentRecordIdGreaterThanOrEqualTo(Long value) { - addCriterion("coupon_agent_record_id >=", value, "couponAgentRecordId"); + public Criteria andConvertCodeGreaterThanOrEqualTo(String value) { + addCriterion("convert_code >=", value, "convertCode"); return (Criteria) this; } - public Criteria andCouponAgentRecordIdLessThan(Long value) { - addCriterion("coupon_agent_record_id <", value, "couponAgentRecordId"); + public Criteria andConvertCodeLessThan(String value) { + addCriterion("convert_code <", value, "convertCode"); return (Criteria) this; } - public Criteria andCouponAgentRecordIdLessThanOrEqualTo(Long value) { - addCriterion("coupon_agent_record_id <=", value, "couponAgentRecordId"); + public Criteria andConvertCodeLessThanOrEqualTo(String value) { + addCriterion("convert_code <=", value, "convertCode"); return (Criteria) this; } - public Criteria andCouponAgentRecordIdIn(List values) { - addCriterion("coupon_agent_record_id in", values, "couponAgentRecordId"); + public Criteria andConvertCodeLike(String value) { + addCriterion("convert_code like", value, "convertCode"); return (Criteria) this; } - public Criteria andCouponAgentRecordIdNotIn(List values) { - addCriterion("coupon_agent_record_id not in", values, "couponAgentRecordId"); + public Criteria andConvertCodeNotLike(String value) { + addCriterion("convert_code not like", value, "convertCode"); return (Criteria) this; } - public Criteria andCouponAgentRecordIdBetween(Long value1, Long value2) { - addCriterion("coupon_agent_record_id between", value1, value2, "couponAgentRecordId"); + public Criteria andConvertCodeIn(List values) { + addCriterion("convert_code in", values, "convertCode"); return (Criteria) this; } - public Criteria andCouponAgentRecordIdNotBetween(Long value1, Long value2) { - addCriterion("coupon_agent_record_id not between", value1, value2, "couponAgentRecordId"); + public Criteria andConvertCodeNotIn(List values) { + addCriterion("convert_code not in", values, "convertCode"); + return (Criteria) this; + } + + public Criteria andConvertCodeBetween(String value1, String value2) { + addCriterion("convert_code between", value1, value2, "convertCode"); + return (Criteria) this; + } + + public Criteria andConvertCodeNotBetween(String value1, String value2) { + addCriterion("convert_code not between", value1, value2, "convertCode"); + return (Criteria) this; + } + + public Criteria andCouponCodeIdIsNull() { + addCriterion("coupon_code_id is null"); + return (Criteria) this; + } + + public Criteria andCouponCodeIdIsNotNull() { + addCriterion("coupon_code_id is not null"); + return (Criteria) this; + } + + public Criteria andCouponCodeIdEqualTo(Long value) { + addCriterion("coupon_code_id =", value, "couponCodeId"); + return (Criteria) this; + } + + public Criteria andCouponCodeIdNotEqualTo(Long value) { + addCriterion("coupon_code_id <>", value, "couponCodeId"); + return (Criteria) this; + } + + public Criteria andCouponCodeIdGreaterThan(Long value) { + addCriterion("coupon_code_id >", value, "couponCodeId"); + return (Criteria) this; + } + + public Criteria andCouponCodeIdGreaterThanOrEqualTo(Long value) { + addCriterion("coupon_code_id >=", value, "couponCodeId"); + return (Criteria) this; + } + + public Criteria andCouponCodeIdLessThan(Long value) { + addCriterion("coupon_code_id <", value, "couponCodeId"); + return (Criteria) this; + } + + public Criteria andCouponCodeIdLessThanOrEqualTo(Long value) { + addCriterion("coupon_code_id <=", value, "couponCodeId"); + return (Criteria) this; + } + + public Criteria andCouponCodeIdIn(List values) { + addCriterion("coupon_code_id in", values, "couponCodeId"); + return (Criteria) this; + } + + public Criteria andCouponCodeIdNotIn(List values) { + addCriterion("coupon_code_id not in", values, "couponCodeId"); + return (Criteria) this; + } + + public Criteria andCouponCodeIdBetween(Long value1, Long value2) { + addCriterion("coupon_code_id between", value1, value2, "couponCodeId"); + return (Criteria) this; + } + + public Criteria andCouponCodeIdNotBetween(Long value1, Long value2) { + addCriterion("coupon_code_id not between", value1, value2, "couponCodeId"); return (Criteria) this; } diff --git a/hai-service/src/main/java/com/hai/entity/HighCouponAgentRel.java b/hai-service/src/main/java/com/hai/entity/HighCouponAgentRel.java index 78f33d29..57d98c69 100644 --- a/hai-service/src/main/java/com/hai/entity/HighCouponAgentRel.java +++ b/hai-service/src/main/java/com/hai/entity/HighCouponAgentRel.java @@ -21,6 +21,11 @@ public class HighCouponAgentRel extends HighCouponAgentRelModel implements Seria */ private Long id; + /** + * 类型 1:销售码 2:兑换码 + */ + private Integer type; + /** * 卡券名称 */ @@ -87,6 +92,14 @@ public class HighCouponAgentRel extends HighCouponAgentRelModel implements Seria this.id = id; } + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + public String getCouponName() { return couponName; } @@ -204,6 +217,7 @@ public class HighCouponAgentRel extends HighCouponAgentRelModel implements Seria } HighCouponAgentRel other = (HighCouponAgentRel) that; return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) + && (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType())) && (this.getCouponName() == null ? other.getCouponName() == null : this.getCouponName().equals(other.getCouponName())) && (this.getSalesPrice() == null ? other.getSalesPrice() == null : this.getSalesPrice().equals(other.getSalesPrice())) && (this.getCouponId() == null ? other.getCouponId() == null : this.getCouponId().equals(other.getCouponId())) @@ -224,6 +238,7 @@ public class HighCouponAgentRel extends HighCouponAgentRelModel implements Seria final int prime = 31; int result = 1; result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); + result = prime * result + ((getType() == null) ? 0 : getType().hashCode()); result = prime * result + ((getCouponName() == null) ? 0 : getCouponName().hashCode()); result = prime * result + ((getSalesPrice() == null) ? 0 : getSalesPrice().hashCode()); result = prime * result + ((getCouponId() == null) ? 0 : getCouponId().hashCode()); @@ -247,6 +262,7 @@ public class HighCouponAgentRel extends HighCouponAgentRelModel implements Seria sb.append(" ["); sb.append("Hash = ").append(hashCode()); sb.append(", id=").append(id); + sb.append(", type=").append(type); sb.append(", couponName=").append(couponName); sb.append(", salesPrice=").append(salesPrice); sb.append(", couponId=").append(couponId); diff --git a/hai-service/src/main/java/com/hai/entity/HighCouponAgentRelExample.java b/hai-service/src/main/java/com/hai/entity/HighCouponAgentRelExample.java index 3d82ecff..59ebd92c 100644 --- a/hai-service/src/main/java/com/hai/entity/HighCouponAgentRelExample.java +++ b/hai-service/src/main/java/com/hai/entity/HighCouponAgentRelExample.java @@ -186,6 +186,66 @@ public class HighCouponAgentRelExample { return (Criteria) this; } + public Criteria andTypeIsNull() { + addCriterion("`type` is null"); + return (Criteria) this; + } + + public Criteria andTypeIsNotNull() { + addCriterion("`type` is not null"); + return (Criteria) this; + } + + public Criteria andTypeEqualTo(Integer value) { + addCriterion("`type` =", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeNotEqualTo(Integer value) { + addCriterion("`type` <>", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeGreaterThan(Integer value) { + addCriterion("`type` >", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeGreaterThanOrEqualTo(Integer value) { + addCriterion("`type` >=", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeLessThan(Integer value) { + addCriterion("`type` <", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeLessThanOrEqualTo(Integer value) { + addCriterion("`type` <=", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeIn(List values) { + addCriterion("`type` in", values, "type"); + return (Criteria) this; + } + + public Criteria andTypeNotIn(List values) { + addCriterion("`type` not in", values, "type"); + return (Criteria) this; + } + + public Criteria andTypeBetween(Integer value1, Integer value2) { + addCriterion("`type` between", value1, value2, "type"); + return (Criteria) this; + } + + public Criteria andTypeNotBetween(Integer value1, Integer value2) { + addCriterion("`type` not between", value1, value2, "type"); + return (Criteria) this; + } + public Criteria andCouponNameIsNull() { addCriterion("coupon_name is null"); return (Criteria) this; diff --git a/hai-service/src/main/java/com/hai/service/HighCouponAgentService.java b/hai-service/src/main/java/com/hai/service/HighCouponAgentService.java index 60f1f27b..bf526f8f 100644 --- a/hai-service/src/main/java/com/hai/service/HighCouponAgentService.java +++ b/hai-service/src/main/java/com/hai/service/HighCouponAgentService.java @@ -35,7 +35,7 @@ public interface HighCouponAgentService { * @Description 根据卡券id和代理商id 查询 * @Date 2021/4/20 23:52 **/ - HighCouponAgentRel getRelByCouponAgent(Long couponId,Long agentId); + HighCouponAgentRel getRelByCouponAgent(Long couponId,Long agentId, Integer type); /** * @Author 胡锐 @@ -78,7 +78,7 @@ public interface HighCouponAgentService { * @Description 根据代理商 查询销售统计 * @Date 2021/4/22 22:26 **/ - Map getSalesCountByAgent(Long agentId) throws Exception; + Map getSalesCountByAgent(Long agentId, Integer type) throws Exception; /** * @@ -104,4 +104,25 @@ public interface HighCouponAgentService { */ List getAgentSalesCodeList(Long agentId,String consumeTimeS,String consumeTimeE); + /** + * 生成兑换码 + * @param couponAgentRelId + * @return + */ + String generateConvertCode(Long couponAgentRelId); + + /** + * 查询兑换码 + * @param convertCode + * @return + */ + HighCouponAgentCode getConvertCode(String convertCode); + + /** + * 使用兑换码 + * @param code + * @return + */ + String useConvertCode(String code); + } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighCouponAgentServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighCouponAgentServiceImpl.java index 885d53b0..d9c312de 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighCouponAgentServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighCouponAgentServiceImpl.java @@ -1,6 +1,7 @@ package com.hai.service.impl; import com.github.pagehelper.PageInfo; +import com.hai.common.GenerateCode; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; @@ -15,6 +16,7 @@ import com.hai.service.*; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; @@ -54,13 +56,9 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { private HighAgentService highAgentService; @Override + @Transactional(propagation= Propagation.REQUIRES_NEW) public void assignCouponAgent(HighCouponAgentRel highCouponAgentRel,Integer stockCount) { - // 查询未销售的卡券 - List codeList = highCouponCodeService.getNoSaleCode(highCouponAgentRel.getCouponId()); - if (stockCount > codeList.size()) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法分配,分配数量超过库存数量"); - } if (highCouponAgentRel.getId() != null) { highCouponAgentRelMapper.updateByPrimaryKey(highCouponAgentRel); } else { @@ -87,26 +85,50 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { record.setCreateTime(new Date()); highCouponAgentRecordMapper.insert(record); - List assignCouponCodeList = codeList.stream().limit(stockCount).collect(Collectors.toList()); - HighCouponAgentCode highCouponAgentCode; - for (HighCouponCode code : assignCouponCodeList) { - code.setAgentId(highCouponAgentRel.getAgentId()); - code.setIsAssignAgent(true); - highCouponCodeService.updateCouponCode(code); - - highCouponAgentCode = new HighCouponAgentCode(); - highCouponAgentCode.setCouponAgentId(highCouponAgentRel.getId()); - highCouponAgentCode.setCouponAgentRecordId(record.getId()); - highCouponAgentCode.setCouponId(code.getCouponId()); - highCouponAgentCode.setAgentId(highCouponAgentRel.getAgentId()); - highCouponAgentCode.setCouponCodeId(code.getId()); - highCouponAgentCode.setCouponCode(code.getSalesCode()); - highCouponAgentCode.setQrCode(code.getExt1()); - highCouponAgentCode.setStatus(1); - highCouponAgentCode.setCreateTime(new Date()); - highCouponAgentCode.setOperatorId(highCouponAgentRel.getOperatorId()); - highCouponAgentCode.setOperatorName(highCouponAgentRel.getOperatorName()); - highCouponAgentCodeMapper.insert(highCouponAgentCode); + if (highCouponAgentRel.getType() == 1) { + // 查询未销售的卡券 + List codeList = highCouponCodeService.getNoSaleCode(highCouponAgentRel.getCouponId()); + if (stockCount > codeList.size()) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法分配,分配数量超过库存数量"); + } + List assignCouponCodeList = codeList.stream().limit(stockCount).collect(Collectors.toList()); + HighCouponAgentCode highCouponAgentCode; + for (HighCouponCode code : assignCouponCodeList) { + code.setAgentId(highCouponAgentRel.getAgentId()); + code.setIsAssignAgent(true); + highCouponCodeService.updateCouponCode(code); + + highCouponAgentCode = new HighCouponAgentCode(); + highCouponAgentCode.setCouponAgentId(highCouponAgentRel.getId()); + highCouponAgentCode.setCouponAgentRecordId(record.getId()); + highCouponAgentCode.setCouponId(code.getCouponId()); + highCouponAgentCode.setAgentId(highCouponAgentRel.getAgentId()); + highCouponAgentCode.setCouponCodeId(code.getId()); + highCouponAgentCode.setCouponCode(code.getSalesCode()); + highCouponAgentCode.setQrCode(code.getExt1()); + highCouponAgentCode.setStatus(1); + highCouponAgentCode.setCreateTime(new Date()); + highCouponAgentCode.setOperatorId(highCouponAgentRel.getOperatorId()); + highCouponAgentCode.setOperatorName(highCouponAgentRel.getOperatorName()); + highCouponAgentCodeMapper.insert(highCouponAgentCode); + } + } + + if (highCouponAgentRel.getType() == 2) { + HighCouponAgentCode highCouponAgentCode; + for (int i = 0; i < stockCount; i++) { + highCouponAgentCode = new HighCouponAgentCode(); + highCouponAgentCode.setCouponAgentId(highCouponAgentRel.getId()); + highCouponAgentCode.setCouponAgentRecordId(record.getId()); + highCouponAgentCode.setCouponId(highCoupon.getId()); + highCouponAgentCode.setAgentId(highCouponAgentRel.getAgentId()); + highCouponAgentCode.setConvertCode(generateConvertCode(highCouponAgentRel.getId())); + highCouponAgentCode.setStatus(1); + highCouponAgentCode.setCreateTime(new Date()); + highCouponAgentCode.setOperatorId(highCouponAgentRel.getOperatorId()); + highCouponAgentCode.setOperatorName(highCouponAgentRel.getOperatorName()); + highCouponAgentCodeMapper.insert(highCouponAgentCode); + } } } @@ -116,9 +138,9 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { } @Override - public HighCouponAgentRel getRelByCouponAgent(Long couponId, Long agentId) { + public HighCouponAgentRel getRelByCouponAgent(Long couponId, Long agentId,Integer type) { HighCouponAgentRelExample example = new HighCouponAgentRelExample(); - example.createCriteria().andCouponIdEqualTo(couponId).andAgentIdEqualTo(agentId); + example.createCriteria().andCouponIdEqualTo(couponId).andAgentIdEqualTo(agentId).andTypeEqualTo(type); List list = highCouponAgentRelMapper.selectByExample(example); if (list != null && list.size() > 0) { return list.get(0); @@ -131,6 +153,10 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { HighCouponAgentRelExample example = new HighCouponAgentRelExample(); HighCouponAgentRelExample.Criteria criteria = example.createCriteria(); + if (MapUtils.getInteger(map, "type") != null) { + criteria.andTypeEqualTo(MapUtils.getInteger(map, "type")); + } + if (MapUtils.getLong(map, "couponId") != null) { criteria.andCouponIdEqualTo(MapUtils.getLong(map, "couponId")); } @@ -213,15 +239,19 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { couponAgentCode.setRemark(remark); highCouponAgentCodeMapper.updateByPrimaryKey(couponAgentCode); - HighCouponAgentRel couponAgent = getRelByCouponAgent(couponAgentCode.getCouponId(), couponAgentCode.getAgentId()); + HighCouponAgentRel couponAgent = getRelByCouponAgent(couponAgentCode.getCouponId(), couponAgentCode.getAgentId(), couponAgentCode.getType()); couponAgent.setStockCount(couponAgent.getStockCount() - 1); couponAgent.setSalesCount(couponAgent.getSalesCount() + 1); highCouponAgentRelMapper.updateByPrimaryKey(couponAgent); - HighCouponCode couponCode = highCouponCodeService.getCouponCodeById(couponAgentCode.getCouponCodeId()); - couponCode.setStatus(2); - couponCode.setReceiveTime(new Date()); - highCouponCodeService.updateCouponCode(couponCode); + + HighCouponCode couponCode = null; + if (couponAgentCode.getType() == 1) { + couponCode = highCouponCodeService.getCouponCodeById(couponAgentCode.getCouponCodeId()); + couponCode.setStatus(2); + couponCode.setReceiveTime(new Date()); + highCouponCodeService.updateCouponCode(couponCode); + } Map map = new HashMap<>(); map.put("couponInfo", highCouponService.getCouponById(couponAgentCode.getCouponId())); @@ -231,12 +261,13 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { } @Override - public Map getSalesCountByAgent(Long agentId) throws Exception { + public Map getSalesCountByAgent(Long agentId, Integer type) throws Exception { BigDecimal surplusCountPrice = new BigDecimal("0"); BigDecimal salesCountPrice = new BigDecimal("0"); Map listMap = new HashMap<>(); listMap.put("agentId", agentId); + listMap.put("type", type); List list = getCouponAgentList(listMap).stream().sorted(Comparator.comparing(HighCouponAgentRel::getSalesPrice)).collect(Collectors.toList()); for (HighCouponAgentRel highCouponAgentRel : list) { BigDecimal surplusPrice = new BigDecimal(highCouponAgentRel.getStockCount()).multiply((highCouponAgentRel.getSalesPrice())); @@ -246,7 +277,7 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { salesCountPrice = salesCountPrice.add(salesPrice); } - // 计算使用有效期 + // 当前日时间 Calendar consumeTimeS = Calendar.getInstance(); consumeTimeS.setTime(new Date()); consumeTimeS.set(Calendar.HOUR_OF_DAY, 00); @@ -265,8 +296,8 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { returnMap.put("orderCount", agentSales.getCount()); returnMap.put("turnoverPrice", agentSales.getSalesCountPrice()); - returnMap.put("laveStockCount", highCouponAgentRelMapper.getAgentCodeCount(agentId, "1")); // 库存数量 - returnMap.put("soldCount", highCouponAgentRelMapper.getAgentCodeCount(agentId, "2,3")); // 销售数量 + returnMap.put("laveStockCount", highCouponAgentRelMapper.getAgentCodeCount(agentId, "1", type)); // 库存数量 + returnMap.put("soldCount", highCouponAgentRelMapper.getAgentCodeCount(agentId, "2,3", type)); // 销售数量 returnMap.put("surplusCountPrice", surplusCountPrice); // 剩余总额 returnMap.put("salesCountPrice", salesCountPrice); // 销售总额 @@ -312,4 +343,52 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { } return new ArrayList<>(); } + + @Override + public String generateConvertCode(Long couponAgentRelId) { + // 生成兑换码 + String code = GenerateCode.convertCode(couponAgentRelId); + if (getConvertCode(code) != null){ + return generateConvertCode(couponAgentRelId); + } + return code; + } + + @Override + public HighCouponAgentCode getConvertCode(String convertCode) { + HighCouponAgentCodeExample example = new HighCouponAgentCodeExample(); + example.createCriteria().andConvertCodeEqualTo(convertCode); + List list = highCouponAgentCodeMapper.selectByExample(example); + if (list.size() > 0) { + return list.get(0); + } + return null; + } + + @Override + @Transactional(propagation= Propagation.REQUIRES_NEW,isolation= Isolation.SERIALIZABLE) + public String useConvertCode(String code) { + // 查询兑换码 + HighCouponAgentCode convertCode = getConvertCode(code); + if (convertCode == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无效的兑换码"); + } + if (convertCode.getStatus() != 1) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "兑换码已被使用"); + } + // 查询未销售的卡券 + List codeList = highCouponCodeService.getNoSaleCode(convertCode.getCouponId()); + if (codeList.size() == 0) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂时无法使用兑换码"); + } + HighCouponCode couponCode = codeList.get(0); + + convertCode.setCouponCodeId(couponCode.getId()); + convertCode.setCouponCode(couponCode.getSalesCode()); + convertCode.setQrCode(couponCode.getExt1()); + convertCode.setStatus(2); + highCouponAgentCodeMapper.updateByPrimaryKey(convertCode); + + return "/couponCode/"+couponCode.getExt1(); + } } From f5362ff802a8382d1be37ffa64212dd771f28f9d Mon Sep 17 00:00:00 2001 From: Sum1Dream <418471657@qq.com> Date: Tue, 4 Jan 2022 17:19:51 +0800 Subject: [PATCH 8/9] 1 --- .../HighDiscountPackageController.java | 2 +- .../bweb/controller/HighTestController.java | 2 +- .../src/main/resources/dev/application.yml | 4 +- .../src/main/resources/pre/application.yml | 2 +- .../main/java/com/cweb/config/AuthConfig.java | 1 - .../cweb/controller/CmsContentController.java | 2 +- .../cweb/controller/HighCouponController.java | 3 - .../OutRechargeOrderController.java | 19 +-- .../src/main/resources/pre/application.yml | 2 +- hai-cweb/src/test/common/test.java | 4 +- .../java/com/hai/dao/CmsContentMapperExt.java | 65 ++++++++- .../com/hai/service/CmsContentService.java | 13 ++ .../service/HighDiscountPackageService.java | 10 ++ .../com/hai/service/HighDiscountService.java | 1 + .../java/com/hai/service/HighTestService.java | 33 +++++ .../service/impl/CmsContentServiceImpl.java | 5 + .../impl/HighDiscountPackageServiceImpl.java | 97 +++++++++++++ .../hai/service/impl/HighTestServiceImpl.java | 136 ++++++++++++++++++ .../hai/service/impl/HighUserServiceImpl.java | 3 + .../impl/HltUnionCardVipServiceImpl.java | 2 - 20 files changed, 381 insertions(+), 25 deletions(-) create mode 100644 hai-service/src/main/java/com/hai/service/HighTestService.java create mode 100644 hai-service/src/main/java/com/hai/service/impl/HighTestServiceImpl.java diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighDiscountPackageController.java b/hai-bweb/src/main/java/com/bweb/controller/HighDiscountPackageController.java index b4d9072a..ae72ed98 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighDiscountPackageController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighDiscountPackageController.java @@ -252,7 +252,7 @@ public class HighDiscountPackageController { highDiscountPackage.setCompanyId(highDiscountPackages.getCompanyId()); highDiscountPackage.setCreatedUserId(highDiscountPackages.getCreatedUserId()); highDiscountPackage.setCreatedTime(highDiscountPackages.getCreatedTime()); - highDiscountPackage.setTotalStock(highDiscountPackage.getTotalStock()); + highDiscountPackage.setTotalStock(highDiscountPackages.getTotalStock()); highDiscountPackageService.updateDiscountPackage(highDiscountPackage); diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java b/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java index f4161e99..ed309457 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java @@ -1 +1 @@ -package com.bweb.controller; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.pay.util.XmlUtil; import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.WxUtils; import com.hai.config.*; import com.hai.dao.HighGasOrderPushMapper; import com.hai.entity.*; import com.hai.model.HighMerchantModel; import com.hai.model.HighMerchantStoreModel; import com.hai.model.ResponseData; import com.hai.model.ResultProfitSharing; import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.ssl.SSLContexts; import org.apache.http.util.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; import javax.net.ssl.SSLContext; import java.io.FileInputStream; import java.math.BigDecimal; import java.security.KeyStore; import java.util.*; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/test") @Api(value = "订单接口") public class HighTestController { private static Logger log = LoggerFactory.getLogger(HighTestController.class); @Resource private HltUnionCardVipService hltUnionCardVipService; @RequestMapping(value = "/getBackendToken", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取访问令牌backendToken") public ResponseData getBackendToken() { try { return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/TCheckEMsgUnionCardVipRights", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "请求会员体系") public ResponseData TCheckEMsgUnionCardVipRights(@RequestParam(name = "phone", required = true) String phone) { try { JSONObject consumptionRecord = HuiLianTongUnionCardConfig.TCheckEMsgUnionCardVipRights(phone); JSONObject cardInfoObject = HuiLianTongUnionCardConfig.resolveResponse(consumptionRecord.getString("data")); return ResponseMsgUtil.success(cardInfoObject); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/GetMembershipLevel", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "请求会员体系") public ResponseData GetMembershipLevel(@RequestParam(name = "phone", required = true) String phone , @RequestParam(name = "regionId", required = true) String regionId ) { try { return ResponseMsgUtil.success(hltUnionCardVipService.GetMembershipLevel(phone , regionId)); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value="/resolveResponse",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "解析") public ResponseData resolveResponse( @RequestParam(name = "data", required = false) String data ) { try { JSONObject cardInfoObject = HuiLianTongUnionCardConfig.resolveResponse(data); return ResponseMsgUtil.success(cardInfoObject); } catch (Exception e) { log.error("getUserByTelephone",e); return ResponseMsgUtil.exception(e); } } } \ No newline at end of file +package com.bweb.controller; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.pay.util.XmlUtil; import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.WxUtils; import com.hai.config.*; import com.hai.dao.HighGasOrderPushMapper; import com.hai.entity.*; import com.hai.model.HighMerchantModel; import com.hai.model.HighMerchantStoreModel; import com.hai.model.ResponseData; import com.hai.model.ResultProfitSharing; import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.ssl.SSLContexts; import org.apache.http.util.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; import javax.net.ssl.SSLContext; import java.io.FileInputStream; import java.math.BigDecimal; import java.security.KeyStore; import java.util.*; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/test") @Api(value = "订单接口") public class HighTestController { private static Logger log = LoggerFactory.getLogger(HighTestController.class); @Resource private HltUnionCardVipService hltUnionCardVipService; @Resource private HighTestService highTestService; // @RequestMapping(value = "/getBackendToken", method = RequestMethod.GET) // @ResponseBody // @ApiOperation(value = "获取访问令牌backendToken") // public ResponseData getBackendToken() { // try { // return ResponseMsgUtil.success(null); // } catch (Exception e) { // log.error("HighOrderController --> getBackendToken() error!", e); // return ResponseMsgUtil.exception(e); // } // } // // @RequestMapping(value = "/TCheckEMsgUnionCardVipRights", method = RequestMethod.GET) // @ResponseBody // @ApiOperation(value = "请求会员体系") // public ResponseData TCheckEMsgUnionCardVipRights(@RequestParam(name = "phone", required = true) String phone) { // try { // JSONObject consumptionRecord = HuiLianTongUnionCardConfig.TCheckEMsgUnionCardVipRights(phone); // JSONObject cardInfoObject = HuiLianTongUnionCardConfig.resolveResponse(consumptionRecord.getString("data")); // return ResponseMsgUtil.success(cardInfoObject); // } catch (Exception e) { // log.error("HighOrderController --> getBackendToken() error!", e); // return ResponseMsgUtil.exception(e); // } // } // // // @RequestMapping(value = "/GetMembershipLevel", method = RequestMethod.GET) // @ResponseBody // @ApiOperation(value = "请求会员体系") // public ResponseData GetMembershipLevel(@RequestParam(name = "phone", required = true) String phone , @RequestParam(name = "regionId", required = true) String regionId ) { // try { // return ResponseMsgUtil.success(hltUnionCardVipService.GetMembershipLevel(phone , regionId)); // } catch (Exception e) { // log.error("HighOrderController --> getBackendToken() error!", e); // return ResponseMsgUtil.exception(e); // } // } // // // @RequestMapping(value="/resolveResponse",method = RequestMethod.GET) // @ResponseBody // @ApiOperation(value = "解析") // public ResponseData resolveResponse( // @RequestParam(name = "data", required = false) String data // ) { // try { // JSONObject cardInfoObject = HuiLianTongUnionCardConfig.resolveResponse(data); // return ResponseMsgUtil.success(cardInfoObject); // // } catch (Exception e) { // log.error("getUserByTelephone",e); // return ResponseMsgUtil.exception(e); // } // } // // @RequestMapping(value="/getReadFile",method = RequestMethod.GET) // @ResponseBody // @ApiOperation(value = "存入用户信息") // public ResponseData getReadFile() { // try { // highTestService.getReadFile(); // return ResponseMsgUtil.success(null); // } catch (Exception e) { // log.error("getUserByTelephone",e); // return ResponseMsgUtil.exception(e); // } // } // @RequestMapping(value="/getUserDiscount",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "赠送优惠券") public ResponseData getUserDiscount(@RequestParam(name = "id", required = true) Long id) { try { highTestService.getUserDiscount(id); return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("getUserByTelephone",e); return ResponseMsgUtil.exception(e); } } } \ No newline at end of file diff --git a/hai-bweb/src/main/resources/dev/application.yml b/hai-bweb/src/main/resources/dev/application.yml index f799126d..6dbeaaea 100644 --- a/hai-bweb/src/main/resources/dev/application.yml +++ b/hai-bweb/src/main/resources/dev/application.yml @@ -28,11 +28,11 @@ spring: poolPreparedStatements: true maxOpenPreparedStatements: 20 redis: - database: 0 + database: 5 host: 139.159.177.244 port: 36379 password: HF123456.Redis - timeout: 1000 + timeout: 36000000 jedis: pool: max-active: 20 diff --git a/hai-bweb/src/main/resources/pre/application.yml b/hai-bweb/src/main/resources/pre/application.yml index 4c2e5f66..f945f8c0 100644 --- a/hai-bweb/src/main/resources/pre/application.yml +++ b/hai-bweb/src/main/resources/pre/application.yml @@ -9,7 +9,7 @@ debug: false #datasource数据源设置 spring: datasource: - url: jdbc:mysql://139.159.177.244:3306/hsg_pre?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false + url: jdbc:mysql://122.9.135.148:3306/hsg?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false username: root password: HF123456. type: com.alibaba.druid.pool.DruidDataSource diff --git a/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java b/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java index c119e8c6..f86a14d9 100644 --- a/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java +++ b/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java @@ -129,7 +129,6 @@ public class AuthConfig implements WebMvcConfigurer { .excludePathPatterns("/highBrand/*") .excludePathPatterns("/highGoodsType/*") .excludePathPatterns("/sendSms/*") - .excludePathPatterns("/test/*") .excludePathPatterns("/sms/*") ; } diff --git a/hai-cweb/src/main/java/com/cweb/controller/CmsContentController.java b/hai-cweb/src/main/java/com/cweb/controller/CmsContentController.java index 26c25e49..a8945cfa 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/CmsContentController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/CmsContentController.java @@ -55,7 +55,7 @@ public class CmsContentController { map.put("companyId", bsCompany.getId().toString()); map.put("status", "2"); map.put("categoryCode", categoryCode); - return ResponseMsgUtil.success(cmsContentService.getListContent(map)); + return ResponseMsgUtil.success(cmsContentService.getListContentByCrest(map)); } } return ResponseMsgUtil.success(new ArrayList<>()); diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighCouponController.java b/hai-cweb/src/main/java/com/cweb/controller/HighCouponController.java index ddee2d97..faebbc10 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighCouponController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighCouponController.java @@ -53,9 +53,6 @@ public class HighCouponController { @Resource private HighCouponCodeService highCouponCodeService; - @Resource - private HighOrderService highOrderService; - @Resource private HighUserCouponService highUserCouponService; diff --git a/hai-cweb/src/main/java/com/cweb/controller/OutRechargeOrderController.java b/hai-cweb/src/main/java/com/cweb/controller/OutRechargeOrderController.java index 3028651a..7e469d5d 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/OutRechargeOrderController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/OutRechargeOrderController.java @@ -122,15 +122,16 @@ public class OutRechargeOrderController { // 支付类型 1.微信支付 outRechargeOrder.setPayType(1); // 判断充值模式:1 电信 2. 移动 3. 联通 - JSONObject telObject = telApiService.outApiTel(outRechargeOrder.getRechargeContent()); - if (telObject.get("status").equals(0)) { - JSONObject o = telObject.getObject("result",JSONObject.class); - // 拼接内容 - remarks = o.get("province").toString() + o.get("company").toString() + "充值" + outRechargeOrder.getOrderPrice() + "元"; - } else { - log.error("orderToPay error!"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.PHONE_NUM_IS_ERROR); - } + // 拼接内容 + remarks = outRechargeOrder.getRechargeContent() + "充值" + outRechargeOrder.getOrderPrice() + "元"; +// JSONObject telObject = telApiService.outApiTel(outRechargeOrder.getRechargeContent()); +// if (telObject.get("status").equals(0)) { +// JSONObject o = telObject.getObject("result",JSONObject.class); +// +// } else { +// log.error("orderToPay error!"); +// throw ErrorHelp.genException(SysCode.System, ErrorCode.PHONE_NUM_IS_ERROR); +// } HighDiscountUserRel highDiscountUserRel = null; if (outRechargeOrder.getMemDiscountId() != null) { diff --git a/hai-cweb/src/main/resources/pre/application.yml b/hai-cweb/src/main/resources/pre/application.yml index 1012ea5c..f425a243 100644 --- a/hai-cweb/src/main/resources/pre/application.yml +++ b/hai-cweb/src/main/resources/pre/application.yml @@ -9,7 +9,7 @@ debug: false #datasource数据源设置 spring: datasource: - url: jdbc:mysql://139.159.177.244:3306/hsg_pre?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false + url: jdbc:mysql://122.9.135.148:3306/hsg?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false username: root password: HF123456. type: com.alibaba.druid.pool.DruidDataSource diff --git a/hai-cweb/src/test/common/test.java b/hai-cweb/src/test/common/test.java index d88c1ee4..41a01fe1 100644 --- a/hai-cweb/src/test/common/test.java +++ b/hai-cweb/src/test/common/test.java @@ -46,7 +46,7 @@ public class test { @Test public void test(){ -/* List codeList = highDiscountAgentCodeService.getDiscountCodeByDiscountAgentId(55L); + List codeList = highDiscountAgentCodeService.getDiscountCodeByDiscountAgentId(55L); List userList = highUserService.getUserList(); @@ -55,7 +55,7 @@ public class test { // 领取优惠券 highDiscountUserRelService.receiveDiscount(user.getId(), codeList.get(num).getId()); num++; - }*/ + } } diff --git a/hai-service/src/main/java/com/hai/dao/CmsContentMapperExt.java b/hai-service/src/main/java/com/hai/dao/CmsContentMapperExt.java index 1e78cfbd..443f9ff3 100644 --- a/hai-service/src/main/java/com/hai/dao/CmsContentMapperExt.java +++ b/hai-service/src/main/java/com/hai/dao/CmsContentMapperExt.java @@ -44,7 +44,7 @@ public interface CmsContentMapperExt { " AND cc.status = #{status}", " ", "", - "ORDER BY cc.category_code", + "ORDER BY cc.category_code and cc.sort_id", "" }) @Results({ @@ -76,4 +76,67 @@ public interface CmsContentMapperExt { }) List getListContent(Map paramsMap) throws Exception; + + @Select(value = { + "" + }) + @Results({ + @Result(column="id", property="id", jdbcType= JdbcType.BIGINT, id=true), + @Result(column="title", property="title", jdbcType= JdbcType.VARCHAR), + @Result(column="category_id", property="categoryId", jdbcType= JdbcType.BIGINT), + @Result(column="category_code", property="categoryCode", jdbcType= JdbcType.VARCHAR), + @Result(column="description", property="description", jdbcType= JdbcType.VARCHAR), + @Result(column="create_time", property="createTime", jdbcType= JdbcType.TIMESTAMP), + @Result(column="status", property="status", jdbcType= JdbcType.INTEGER), + @Result(column="has_patch", property="hasPatch", jdbcType= JdbcType.TINYINT), + @Result(column="visit_count", property="visitCount", jdbcType= JdbcType.INTEGER), + @Result(column="tag", property="tag", jdbcType= JdbcType.VARCHAR), + @Result(column="img_source", property="imgSource", jdbcType= JdbcType.TINYINT), + @Result(column="img_data", property="imgData", jdbcType= JdbcType.VARCHAR), + @Result(column="jump_type", property="jumpType", jdbcType= JdbcType.INTEGER), + @Result(column="jump_name", property="jumpName", jdbcType= JdbcType.VARCHAR), + @Result(column="jump_url", property="jumpUrl", jdbcType= JdbcType.VARCHAR), + @Result(column="sort_id", property="sortId", jdbcType= JdbcType.INTEGER), + @Result(column="update_time", property="updateTime", jdbcType= JdbcType.TIMESTAMP), + @Result(column="recommend", property="recommend", jdbcType= JdbcType.BIT), + @Result(column="company_id", property="companyId", jdbcType= JdbcType.BIGINT), + @Result(column="op_id", property="opId", jdbcType= JdbcType.BIGINT), + @Result(column="ext_1", property="ext1", jdbcType= JdbcType.VARCHAR), + @Result(column="ext_2", property="ext2", jdbcType= JdbcType.VARCHAR), + @Result(column="ext_3", property="ext3", jdbcType= JdbcType.VARCHAR), + @Result(column="content", property="content", jdbcType= JdbcType.LONGVARCHAR), + @Result(column="category_name", property="categoryName", jdbcType= JdbcType.VARCHAR), + }) + List getListContentByCrest(Map paramsMap) throws Exception; } diff --git a/hai-service/src/main/java/com/hai/service/CmsContentService.java b/hai-service/src/main/java/com/hai/service/CmsContentService.java index 47a64f8d..2f7e7c43 100644 --- a/hai-service/src/main/java/com/hai/service/CmsContentService.java +++ b/hai-service/src/main/java/com/hai/service/CmsContentService.java @@ -85,6 +85,19 @@ public interface CmsContentService { */ List getListContent(Map paramsMap) throws Exception; + + /** + * + * @Title: getListContent + * @Description: 查询内容列表 + * @author: gongjia + * @param: [paramsMap] + * @return: java.util.List + * @throws + */ + List getListContentByCrest(Map paramsMap) throws Exception; + + /** * * @Title: getCorporateAdvertising diff --git a/hai-service/src/main/java/com/hai/service/HighDiscountPackageService.java b/hai-service/src/main/java/com/hai/service/HighDiscountPackageService.java index 7fe0e5c5..e22d3382 100644 --- a/hai-service/src/main/java/com/hai/service/HighDiscountPackageService.java +++ b/hai-service/src/main/java/com/hai/service/HighDiscountPackageService.java @@ -89,4 +89,14 @@ public interface HighDiscountPackageService { */ void addDiscountPackageStock(HighDiscountPackage highDiscountPackage, UserInfoModel userInfoModel , Integer num); + /** + * @Author Sum1Dream + * @name freeUserDiscountPackage.java + * @Description // 赠送用户优惠券包内容 + * @Date 3:09 下午 2021/12/24 + * @Param [java.lang.Long] + * @return void + */ + void freeUserDiscountPackage(Map map) throws Exception; + } diff --git a/hai-service/src/main/java/com/hai/service/HighDiscountService.java b/hai-service/src/main/java/com/hai/service/HighDiscountService.java index 7f60ae30..8661c42b 100644 --- a/hai-service/src/main/java/com/hai/service/HighDiscountService.java +++ b/hai-service/src/main/java/com/hai/service/HighDiscountService.java @@ -39,5 +39,6 @@ public interface HighDiscountService { * @Date 2021/4/3 21:39 **/ List getDiscount(Map map); + } diff --git a/hai-service/src/main/java/com/hai/service/HighTestService.java b/hai-service/src/main/java/com/hai/service/HighTestService.java new file mode 100644 index 00000000..c1ae0656 --- /dev/null +++ b/hai-service/src/main/java/com/hai/service/HighTestService.java @@ -0,0 +1,33 @@ +package com.hai.service; + +/** + * @serviceName HltMerchantService.java + * @author Sum1Dream + * @version 1.0.0 + * @Description // 测试接口 + * @createTime 11:46 上午 2021/12/15 + **/ +public interface HighTestService { + + /** + * @Author Sum1Dream + * @name getReadFile.java + * @Description //读取文件 + * @Date 5:31 下午 2021/12/16 + * @Param [] + * @return void + */ + void getReadFile() throws Exception; + + + /** + * @Author Sum1Dream + * @name getUserDiscount.java + * @Description // 赠送用户卡券 + * @Date 7:14 下午 2021/12/24 + * @Param [] + * @return void + */ + void getUserDiscount(Long id) throws Exception; + +} diff --git a/hai-service/src/main/java/com/hai/service/impl/CmsContentServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/CmsContentServiceImpl.java index f7a883eb..2dac374a 100644 --- a/hai-service/src/main/java/com/hai/service/impl/CmsContentServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/CmsContentServiceImpl.java @@ -178,6 +178,11 @@ public class CmsContentServiceImpl implements CmsContentService { return cmsContentMapper.getListContent(paramsMap); } + @Override + public List getListContentByCrest(Map paramsMap) throws Exception { + return cmsContentMapper.getListContentByCrest(paramsMap); + } + @Override public List getCorporateAdvertising() { CmsContentExample example = new CmsContentExample(); diff --git a/hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageServiceImpl.java index bb336378..5a0f38e6 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageServiceImpl.java @@ -3,12 +3,16 @@ package com.hai.service.impl; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; +import com.hai.common.utils.DateUtil; +import com.hai.common.utils.IDGenerator; +import com.hai.common.utils.RedisUtil; import com.hai.dao.*; import com.hai.entity.*; import com.hai.model.UserInfoModel; import com.hai.service.*; import com.hai.service.HighDiscountPackageService; import org.apache.commons.collections4.MapUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Propagation; @@ -52,6 +56,28 @@ public class HighDiscountPackageServiceImpl implements HighDiscountPackageServic @Resource private HighDiscountInventoryRecordMapper discountInventoryRecordMapper; + @Resource + private HighUserService highUserService; + + @Resource + private HighDiscountPackageService highDiscountPackageService; + + + @Resource + private HighDiscountUserRelMapper highDiscountUserRelMapper; + + @Resource + private HighDiscountService highDiscountService; + + @Resource + private HighDiscountPackageActualService discountPackageActualService; + + @Resource + private HighDiscountPackageDiscountActualService discountPackageDiscountActualService; + + @Autowired + private RedisUtil redisUtil; + @Override public List getDiscountPackageList(Map map) { @@ -223,4 +249,75 @@ public class HighDiscountPackageServiceImpl implements HighDiscountPackageServic highDiscountPackageMapper.updateByPrimaryKey(highDiscountPackage); } + + @Override + @Transactional(propagation= Propagation.REQUIRES_NEW) + public void freeUserDiscountPackage(Map map) throws Exception { + + + HighDiscountPackage highDiscountPackage = highDiscountPackageService.findDiscountPackageById(MapUtils.getInteger(map , "discountPackageId")); + + + // 查询优惠券包实际库存 + HighDiscountPackageActual discountPackageActual = discountPackageActualService.getHighDiscountPackageActualList(highDiscountPackage.getId()).get(0); + + // 修改优惠券包实际库存为已使用 + discountPackageActual.setStatus(0); + discountPackageActual.setUserId(MapUtils.getInteger(map , "userId")); + discountPackageActual.setAllocationTime(new Date()); + discountPackageActualService.updateHighDiscountPackageActual(discountPackageActual); + + // 查询优惠券包实际库存中实际优惠券数量 + List discountPackageDiscountActual = discountPackageDiscountActualService.getHighDiscountPackageDiscountActualList(discountPackageActual.getId()); + + // 循环赠送优惠券 + for (HighDiscountPackageDiscountActual actualList: discountPackageDiscountActual) { + + HighDiscountUserRel highDiscountUserRel = new HighDiscountUserRel(); + highDiscountUserRel.setDiscountId(actualList.getDiscountId()); + highDiscountUserRel.setUserId(MapUtils.getLong(map , "userId")); + highDiscountUserRel.setAgentId(actualList.getAgentId()); + highDiscountUserRel.setDiscountAgentCodeId(actualList.getAgentDiscountCodeId()); + highDiscountUserRel.setStatus(1); + highDiscountUserRel.setCreateTime(new Date()); + + HighDiscount highDiscount = highDiscountService.getDiscountById(actualList.getDiscountId()); + + // 计算使用有效期 + Calendar userEndTime = Calendar.getInstance(); + userEndTime.setTime(new Date()); + userEndTime.set(Calendar.HOUR_OF_DAY, 23); + userEndTime.set(Calendar.MINUTE, 59); + userEndTime.set(Calendar.SECOND, 59); + userEndTime.add(Calendar.DATE, highDiscount.getEffectiveDay()); + highDiscountUserRel.setUseEndTime(userEndTime.getTime()); + + HighDiscountAgentCode discountAgentCode = highDiscountAgentCodeService.getCodeById(actualList.getAgentDiscountCodeId()); + + // 修改优惠券二维码状态 + discountAgentCode.setStatus(2); + highDiscountAgentCodeService.updateCode(discountAgentCode); + + // 新增优惠券与用户的绑定关系 + highDiscountUserRelMapper.insert(highDiscountUserRel); + + // 修改优惠券包实际库存实际优惠券状态 + actualList.setStatus(0); + discountPackageDiscountActualService.updateHighDiscountPackageDiscountActual(actualList); + } + + // 增加赠送记录 + HighDiscountPackageRecord discountPackageRecord = new HighDiscountPackageRecord(); + discountPackageRecord.setDiscountPackageId(highDiscountPackage.getId()); + discountPackageRecord.setDiscountPackageTitle(highDiscountPackage.getTitle()); + discountPackageRecord.setCompanyId(highDiscountPackage.getCompanyId()); + discountPackageRecord.setStatus(1); + discountPackageRecord.setUsingAttribution(1); + discountPackageRecord.setRecordNo("DP" + DateUtil.date2String(new Date(),"yyyyMMddHHmmss") + IDGenerator.nextId(5) ); + discountPackageRecord.setSalesType(2); + discountPackageRecord.setUserId(MapUtils.getInteger(map , "userId")); + discountPackageRecord.setExt1(MapUtils.getString(map , "userPhone")); + discountPackageRecord.setCreatedTime(new Date()); + highDiscountPackageRecordMapper.insert(discountPackageRecord); + } } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighTestServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighTestServiceImpl.java new file mode 100644 index 00000000..c2d2d96b --- /dev/null +++ b/hai-service/src/main/java/com/hai/service/impl/HighTestServiceImpl.java @@ -0,0 +1,136 @@ +package com.hai.service.impl; + + +import com.hai.common.exception.ErrorCode; +import com.hai.common.exception.ErrorHelp; +import com.hai.common.exception.SysCode; +import com.hai.common.utils.RedisUtil; +import com.hai.dao.HighUserEtcMapper; +import com.hai.entity.HighDiscountAgentCode; +import com.hai.entity.HighUser; +import com.hai.entity.HighUserEtc; +import com.hai.service.*; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.math.BigDecimal; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +@Service("highTestService") +public class HighTestServiceImpl implements HighTestService { + + private static Logger log = LoggerFactory.getLogger(HighTestService.class); + + @Resource + private HighUserService highUserService; + + @Resource + private HighUserEtcMapper highUserEtcMapper; + + @Resource + private HighDiscountAgentCodeService highDiscountAgentCodeService; + + + @Resource + private HighDiscountUserRelService highDiscountUserRelService; + + @Autowired + private RedisUtil redisUtil; + + @Override + @Transactional(rollbackFor=Exception.class,propagation= Propagation.REQUIRES_NEW) + public void getReadFile() throws Exception { +// BufferedReader bufferedReader = null; +// +// Map mapUser = new HashMap<>(); +// +// //cookie过期时间为7天 +// int EXPIRE = 3600*24*7; +// +// List highUsers = highUserService.getListUser(mapUser); +// +// for (HighUser user: highUsers) { +// redisUtil.set(user.getPhone(), user.getPhone(), EXPIRE); +// } +// +// FileReader fileReader = new FileReader("/home/project/hsg/readFile/etccq.txt"); +// if (fileReader == null) { +// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "读取空数据"); +// } +// +// bufferedReader = new BufferedReader(fileReader); +// String temp = bufferedReader.readLine(); +// int i = 0; +// while (temp != null) { +// i++; +// String[] arr = temp.split(";"); +// +// String phone = (String) redisUtil.get(arr[3]); +// +// if (phone == null || highUsers.size() == 0) { +// HighUser user = new HighUser(); +// +// user.setStatus(1); +// user.setInfoCompleteStatus(1); +// user.setGold(0); +// user.setRegTime(new Date()); +// user.setName(arr[2]); +// user.setPhone(arr[3]); +// user.setExt4("1"); +// +// highUserService.insertUser(user); +// +// HighUserEtc userEtc = new HighUserEtc(); +// +// userEtc.setCreateTime(new Date()); +// userEtc.setStatus(1); +// userEtc.setUserId(user.getId()); +// userEtc.setCustomerName(arr[2]); +// userEtc.setCustomerTel(arr[3]); +// userEtc.setVehicleId(arr[0]); +// userEtc.setVehiclePlate(arr[1]); +// +// highUserEtcMapper.insert(userEtc); +// +//// Map map = new HashMap<>(); +//// map.put("userId" , user.getId()); +//// map.put("userPhone" , user.getPhone()); +//// map.put("discountPackageId" , 48); +// +//// highDiscountPackageService.freeUserDiscountPackage(map); +// } +// +// temp = bufferedReader.readLine(); +// } + } + + @Override + @Transactional(rollbackFor=Exception.class,propagation= Propagation.REQUIRES_NEW) + public void getUserDiscount(Long id) throws Exception{ + List codeList = highDiscountAgentCodeService.getDiscountCodeByStatus(id , 1); + Map map = new HashMap<>(); + map.put("ext4" , "1"); + List userList = highUserService.getListUser(map); + + int num = 0; + for (HighUser user : userList) { + // 领取优惠券 + highDiscountUserRelService.receiveDiscount(user.getId(), codeList.get(num).getId()); + num++; + } + } +} diff --git a/hai-service/src/main/java/com/hai/service/impl/HighUserServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighUserServiceImpl.java index cb7ff1c5..a50755da 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighUserServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighUserServiceImpl.java @@ -65,6 +65,9 @@ public class HighUserServiceImpl implements HighUserService { if (StringUtils.isNotBlank(map.get("status"))) { criteria.andStatusEqualTo(Integer.valueOf(map.get("status"))); } + if (StringUtils.isNotBlank(map.get("ext4"))) { + criteria.andExt4EqualTo(String.valueOf(map.get("ext4"))); + } if (StringUtils.isNotBlank(map.get("regTimeStart")) && StringUtils.isNotBlank(map.get("regTimeEnd"))) { criteria.andRegTimeBetween( DateUtil.format(map.get("regTimeStart") , "yyyy-MM-dd HH:mm:ss") , diff --git a/hai-service/src/main/java/com/hai/service/impl/HltUnionCardVipServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HltUnionCardVipServiceImpl.java index 872eecba..735e832b 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HltUnionCardVipServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HltUnionCardVipServiceImpl.java @@ -116,8 +116,6 @@ public class HltUnionCardVipServiceImpl implements HltUnionCardVipService { HighDiscountPackage highDiscountPackage = highDiscountPackages.get(0); - highDiscountPackageService.updateDiscountPackage(highDiscountPackage); - // 查询优惠券包实际库存 HighDiscountPackageActual discountPackageActual = discountPackageActualService.getHighDiscountPackageActualList(highDiscountPackage.getId()).get(0); From ec3af40f1d5f420e9b9dea1be6fcd786a5e5e092 Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Wed, 5 Jan 2022 09:14:40 +0800 Subject: [PATCH 9/9] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=B7=B2=E7=9F=A5?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/bweb/controller/HighCouponAgentController.java | 2 ++ .../com/cweb/controller/HighCouponAgentController.java | 2 +- .../hai/service/impl/HighCouponAgentServiceImpl.java | 10 ++++++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighCouponAgentController.java b/hai-bweb/src/main/java/com/bweb/controller/HighCouponAgentController.java index 94d9f79f..78ac2dab 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighCouponAgentController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighCouponAgentController.java @@ -292,6 +292,7 @@ public class HighCouponAgentController { @ResponseBody @ApiOperation(value = "根据代理商和卡券 查询分配的销售码") public ResponseData getCodeListByAgentCoupon(@RequestParam(name = "couponId", required = true) Long couponId, + @RequestParam(name = "type", required = true) Integer type, @RequestParam(name = "status", required = false) String status, @RequestParam(name = "createTimeS", required = false) Long createTimeS, @RequestParam(name = "createTimeE", required = false) Long createTimeE, @@ -309,6 +310,7 @@ public class HighCouponAgentController { Map map = new HashMap<>(); map.put("agentId", userInfoModel.getHighAgent().getId()); + map.put("type", type); map.put("couponId", couponId); map.put("status", status); map.put("createTimeS", createTimeS); diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighCouponAgentController.java b/hai-cweb/src/main/java/com/cweb/controller/HighCouponAgentController.java index 099a751a..5645137b 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighCouponAgentController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighCouponAgentController.java @@ -60,7 +60,7 @@ public class HighCouponAgentController { log.error("HighCouponAgentController -> queryConvertCode() error!","无效的兑换码"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无效的兑换码"); } - if (convertCode.getStatus() != 1) { + if (convertCode.getStatus() == 3) { log.error("HighCouponAgentController -> queryConvertCode() error!","兑换码已被使用"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "兑换码已被使用"); } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighCouponAgentServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighCouponAgentServiceImpl.java index d9c312de..89e1dd80 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighCouponAgentServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighCouponAgentServiceImpl.java @@ -99,6 +99,7 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { highCouponCodeService.updateCouponCode(code); highCouponAgentCode = new HighCouponAgentCode(); + highCouponAgentCode.setType(highCouponAgentRel.getType()); highCouponAgentCode.setCouponAgentId(highCouponAgentRel.getId()); highCouponAgentCode.setCouponAgentRecordId(record.getId()); highCouponAgentCode.setCouponId(code.getCouponId()); @@ -118,6 +119,7 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { HighCouponAgentCode highCouponAgentCode; for (int i = 0; i < stockCount; i++) { highCouponAgentCode = new HighCouponAgentCode(); + highCouponAgentCode.setType(highCouponAgentRel.getType()); highCouponAgentCode.setCouponAgentId(highCouponAgentRel.getId()); highCouponAgentCode.setCouponAgentRecordId(record.getId()); highCouponAgentCode.setCouponId(highCoupon.getId()); @@ -127,7 +129,7 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { highCouponAgentCode.setCreateTime(new Date()); highCouponAgentCode.setOperatorId(highCouponAgentRel.getOperatorId()); highCouponAgentCode.setOperatorName(highCouponAgentRel.getOperatorName()); - highCouponAgentCodeMapper.insert(highCouponAgentCode); + highCouponAgentCodeMapper.insert(highCouponAgentCode); } } } @@ -179,6 +181,10 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { criteria.andCouponAgentIdEqualTo(MapUtils.getLong(map, "couponAgentId")); } + if (MapUtils.getInteger(map, "type") != null) { + criteria.andTypeEqualTo(MapUtils.getInteger(map, "type")); + } + if (MapUtils.getLong(map, "couponId") != null) { criteria.andCouponIdEqualTo(MapUtils.getLong(map, "couponId")); } @@ -373,7 +379,7 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { if (convertCode == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无效的兑换码"); } - if (convertCode.getStatus() != 1) { + if (convertCode.getStatus() == 3) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "兑换码已被使用"); } // 查询未销售的卡券