diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java b/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java new file mode 100644 index 00000000..ca89a70d --- /dev/null +++ b/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java @@ -0,0 +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 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; @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); } } } \ No newline at end of file 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 5dcedbf8..ebb644c7 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.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; @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 = "/unionZwrefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "银联交易撤销") public ResponseData unionZwrefund(@RequestParam(name = "orderNo", required = true) String orderNo, @RequestParam(name = "paySerialNo", required = true) String paySerialNo) { try { return ResponseMsgUtil.success(UnionPayConfig.cancel(orderNo,paySerialNo)); } catch (Exception e) { log.error("HighOrderController --> unionTradeQuery() 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); } } 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.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; @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); } } 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/WechatController.java b/hai-cweb/src/main/java/com/cweb/controller/WechatController.java index ba4a7efd..fe2b16c4 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/WechatController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/WechatController.java @@ -17,6 +17,7 @@ import com.hai.common.exception.SysCode; import com.hai.common.security.SessionObject; import com.hai.common.security.UserCenter; import com.hai.common.utils.HttpsUtils; +import com.hai.common.utils.IDGenerator; import com.hai.common.utils.RedisUtil; import com.hai.common.utils.ResponseMsgUtil; import com.hai.entity.HighUser; @@ -116,6 +117,80 @@ public class WechatController { } } + @RequestMapping(value = "/loginByPhone", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "小程序根据手机号登录或注册") + public ResponseData loginByPhone(@RequestParam(value = "encryptedData", required = true) String encryptedData, + @RequestParam(value = "iv", required = true) String iv, + @RequestParam(value = "openId", required = true) String openId, + HttpServletRequest request, HttpServletResponse response) { + try { + log.error("origin encryptedData:" + encryptedData + ";iv:" + iv); + //校验openId不能为空 + //encryptedData,iv与unionId不能同时为空 + encryptedData = encryptedData.replace(" ", "+"); + iv = iv.replace(" ", "+"); + log.error("dest encryptedData:" + encryptedData + ";iv:" + iv); + if (StringUtils.isEmpty(openId) + || StringUtils.isEmpty(encryptedData) || StringUtils.isEmpty(iv)) { + throw ErrorHelp.genException(SysCode.MiniProgram, ErrorCode.REQ_PARAMS_ERROR, ""); + } + //请求微信api,获取用户session_key以及openId + Object skObject = redisUtil.hget(WX_OPENID_SESSION_REDIS,openId); + if (skObject == null){ + throw ErrorHelp.genException(SysCode.MiniProgram, ErrorCode.WECHAT_LOGIN_ERROR); + } + WxMaJscode2SessionResult session = (WxMaJscode2SessionResult)skObject; + + final WxMaService wxService = WxMaConfiguration.getMaService(); + WxMaPhoneNumberInfo phoneNoInfo = wxService.getUserService().getPhoneNoInfo(session.getSessionKey(), encryptedData, iv); + if (phoneNoInfo == null || StringUtils.isEmpty(phoneNoInfo.getPurePhoneNumber())) { + throw ErrorHelp.genException(SysCode.MiniProgram, ErrorCode.WECHAT_DECRYPT_ERROR, "用户phoneNumber解析失败"); + } + + HighUser user = highUserService.findByOpenId(session.getOpenid()); + if (user != null) { + if (StringUtils.isBlank(user.getPhone())) { + if (highUserService.findByPhone(phoneNoInfo.getPurePhoneNumber()) != null) { + throw ErrorHelp.genException(SysCode.MiniProgram, ErrorCode.COMMON_ERROR, "手机号已被绑定,请更换后重新授权"); + } + user.setPhone(phoneNoInfo.getPurePhoneNumber()); + } + } else { + if (highUserService.findByPhone(phoneNoInfo.getPurePhoneNumber()) != null) { + throw ErrorHelp.genException(SysCode.MiniProgram, ErrorCode.COMMON_ERROR, "手机号已被绑定,请更换后重新授权"); + } + user = new HighUser(); + user.setName("用户" + IDGenerator.nextId(5)); + user.setPhone(phoneNoInfo.getPurePhoneNumber()); + user.setRegTime(new Date()); + user.setGold(0); + user.setOpenId(session.getOpenid()); + user.setUnionId(session.getUnionid()); + user.setStatus(1); + // 用户信息完整状态 + // 0:完整 + // 1:需要填写用户信息 + // 2:需要填写手机号 + user.setInfoCompleteStatus(1); + highUserService.insertUser(user); + } + + // 定义个人所有数据 + HighUserModel highUserModel = new HighUserModel(); + HighUser detailData = highUserService.getDetailDataByUser(user.getId()); + detailData.setPassword(null); + highUserModel.setHighUser(detailData); + SessionObject so = new SessionObject(user.getUnionId(), 1 , highUserModel); + userCenter.save(request, response, so); + + return ResponseMsgUtil.success(so); + + } catch (Exception e) { + return ResponseMsgUtil.exception(e); + } + } + @RequestMapping(value = "/getPhoneNumber", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "小程序获取用户手机号码") @@ -206,8 +281,20 @@ public class WechatController { user.setGold(0); user.setHeaderImg(userInfo.getAvatarUrl()); user.setName(userInfo.getNickName()); + user.setInfoCompleteStatus(2); highUserService.insertUser(user); } else { + // 用户信息完整状态 + // 0:完整 + // 1:需要填写用户信息 + // 2:需要填写手机号 + if (user.getInfoCompleteStatus() == 1) { + if (StringUtils.isNotBlank(user.getPhone())) { + user.setInfoCompleteStatus(0); + } else { + user.setInfoCompleteStatus(2); + } + } user.setUnionId(session.getUnionid()); user.setHeaderImg(userInfo.getAvatarUrl()); user.setName(userInfo.getNickName()); @@ -323,8 +410,20 @@ public class WechatController { user.setGold(0); user.setHeaderImg(userInfo.getString("headimgurl")); user.setName(userInfo.getString("nickname")); + user.setInfoCompleteStatus(2); highUserService.insertUser(user); } else { + // 用户信息完整状态 + // 0:完整 + // 1:需要填写用户信息 + // 2:需要填写手机号 + if (user.getInfoCompleteStatus() == 1) { + if (StringUtils.isNotBlank(user.getPhone())) { + user.setInfoCompleteStatus(0); + } else { + user.setInfoCompleteStatus(2); + } + } user.setOpenIdH5(openid); user.setHeaderImg(userInfo.getString("headimgurl")); user.setName(userInfo.getString("nickname")); diff --git a/hai-schedule/src/main/java/com/hai/config/SwaggerConfig.java b/hai-schedule/src/main/java/com/hai/config/SwaggerConfig.java new file mode 100644 index 00000000..3f09f7a9 --- /dev/null +++ b/hai-schedule/src/main/java/com/hai/config/SwaggerConfig.java @@ -0,0 +1,47 @@ +package com.hai.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +/** +* SwaggerConfig.java +* 项目名称: +* 包: +* 类名称: SwaggerConfig.java +* 类描述: 构建restful api接口文档 +* 创建人: +* 创建时间: 2017 下午4:23:45 +*/ +@Configuration +@EnableSwagger2 +public class SwaggerConfig +{ + + /** + * 描述api的基本信息 + * 基本信息会展现在文档页面中 + * @return [api的基本信息] + */ + ApiInfo apiInfo() + { + return new ApiInfoBuilder().title("hgj-CWeb").description("提供给用户端的接口").termsOfServiceUrl("").version("1.0.0") + .contact(new Contact("", "", "")).build(); + } + + @Bean + public Docket customImplementation() + { + return new Docket(DocumentationType.SWAGGER_2).select() + .apis(RequestHandlerSelectors.basePackage("com")) + .build().directModelSubstitute(org.joda.time.LocalDate.class, java.sql.Date.class) + .directModelSubstitute(org.joda.time.DateTime.class, java.util.Date.class).apiInfo(apiInfo()); + } + +} diff --git a/hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java b/hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java index 5c9143ec..a61bd46d 100644 --- a/hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java +++ b/hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java @@ -68,7 +68,7 @@ public class HighCouponSchedule { * @Description 处理汇联卡券状态 * @Date 2021/4/4 22:44 **/ - @Scheduled(cron="0 0/30 * * * ?") //每30分钟执行一次 + @Scheduled(cron="0 0/10 * * * ?") //每10分钟执行一次 public void handleCouponStatus() throws Exception { HighCouponCodeOtherExample example = new HighCouponCodeOtherExample(); diff --git a/hai-schedule/src/main/java/com/hai/schedule/HighTestController.java b/hai-schedule/src/main/java/com/hai/schedule/HighTestController.java new file mode 100644 index 00000000..ca98a608 --- /dev/null +++ b/hai-schedule/src/main/java/com/hai/schedule/HighTestController.java @@ -0,0 +1 @@ +package com.hai.schedule; 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 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; @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); } } } \ No newline at end of file diff --git a/hai-schedule/src/main/resources/dev/application.yml b/hai-schedule/src/main/resources/dev/application.yml index ff2ce013..b3da0b6b 100644 --- a/hai-schedule/src/main/resources/dev/application.yml +++ b/hai-schedule/src/main/resources/dev/application.yml @@ -27,18 +27,50 @@ spring: testOnReturn: false poolPreparedStatements: true maxOpenPreparedStatements: 20 - #配置日期返回至前台为时间戳 - jackson: - serialization: - write-dates-as-timestamps: true -mybatis: - mapperLocations: - - classpath*:sqlmap*/*.xml - type-aliases-package: - org.springboot.sample.entity - -pagehelper: - helperDialect: mysql - reasonable: true - supportMethodsArguments: true - params: count=countSql + + redis: + database: 0 + host: 139.159.177.244 + port: 36379 + password: HF123456.Redis + timeout: 1000 + jedis: + pool: + max-active: 20 + max-wait: -1 + max-idle: 10 + min-idle: 0 + + #thymelea模板配置 + thymeleaf: + prefix: classpath:/templates/ + suffix: .html + mode: HTML5 + encoding: UTF-8 + #热部署文件,页面不产生缓存,及时更新 + cache: false + #配置日期返回至前台为时间戳 + jackson: + serialization: + write-dates-as-timestamps: true + + + thymeleaf: + cache: false + prefix: classpath:/templates/ + suffix: .html + encoding: UTF-8 + content-type: text/html + mode: HTML5 + + mybatis: + mapperLocations: + - classpath*:sqlmap*/*.xml + type-aliases-package: + org.springboot.sample.entity + + pagehelper: + helperDialect: mysql + reasonable: true + supportMethodsArguments: true + params: count=countSql diff --git a/hai-schedule/src/main/resources/pre/application.yml b/hai-schedule/src/main/resources/pre/application.yml index ff2ce013..b3da0b6b 100644 --- a/hai-schedule/src/main/resources/pre/application.yml +++ b/hai-schedule/src/main/resources/pre/application.yml @@ -27,18 +27,50 @@ spring: testOnReturn: false poolPreparedStatements: true maxOpenPreparedStatements: 20 - #配置日期返回至前台为时间戳 - jackson: - serialization: - write-dates-as-timestamps: true -mybatis: - mapperLocations: - - classpath*:sqlmap*/*.xml - type-aliases-package: - org.springboot.sample.entity - -pagehelper: - helperDialect: mysql - reasonable: true - supportMethodsArguments: true - params: count=countSql + + redis: + database: 0 + host: 139.159.177.244 + port: 36379 + password: HF123456.Redis + timeout: 1000 + jedis: + pool: + max-active: 20 + max-wait: -1 + max-idle: 10 + min-idle: 0 + + #thymelea模板配置 + thymeleaf: + prefix: classpath:/templates/ + suffix: .html + mode: HTML5 + encoding: UTF-8 + #热部署文件,页面不产生缓存,及时更新 + cache: false + #配置日期返回至前台为时间戳 + jackson: + serialization: + write-dates-as-timestamps: true + + + thymeleaf: + cache: false + prefix: classpath:/templates/ + suffix: .html + encoding: UTF-8 + content-type: text/html + mode: HTML5 + + mybatis: + mapperLocations: + - classpath*:sqlmap*/*.xml + type-aliases-package: + org.springboot.sample.entity + + pagehelper: + helperDialect: mysql + reasonable: true + supportMethodsArguments: true + params: count=countSql diff --git a/hai-schedule/src/main/resources/prod/application.yml b/hai-schedule/src/main/resources/prod/application.yml index 8b5b61a4..48d8df81 100644 --- a/hai-schedule/src/main/resources/prod/application.yml +++ b/hai-schedule/src/main/resources/prod/application.yml @@ -27,6 +27,20 @@ spring: testOnReturn: false poolPreparedStatements: true maxOpenPreparedStatements: 20 + + redis: + database: 0 + host: 127.0.0.1 + port: 36379 + password: HF123456.Redis + timeout: 1000 + jedis: + pool: + max-active: 20 + max-wait: -1 + max-idle: 10 + min-idle: 0 + #thymelea模板配置 thymeleaf: prefix: classpath:/templates/ diff --git a/hai-schedule/src/test/common/test.java b/hai-schedule/src/test/common/test.java new file mode 100644 index 00000000..baefa724 --- /dev/null +++ b/hai-schedule/src/test/common/test.java @@ -0,0 +1,98 @@ +package common; + +import com.alibaba.fastjson.JSONObject; +import com.hai.ScheduleApplication; +import com.hai.common.utils.HttpsUtils; +import com.hai.common.utils.RedisUtil; +import com.hai.config.HuiLianTongConfig; +import com.hai.service.HighDiscountAgentCodeService; +import com.hai.service.HighDiscountUserRelService; +import com.hai.service.HighUserService; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.web.WebAppConfiguration; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @ClassName RegionTest + * @Description: TODO () + * @Author 胡锐 + * @Date 2020/12/29 + **/ +@RunWith(SpringJUnit4ClassRunner.class) +@SpringBootTest(classes = ScheduleApplication.class) +@WebAppConfiguration +public class test { + + @Resource + private HighUserService highUserService; + + @Resource + private HighDiscountUserRelService highDiscountUserRelService; + + @Resource + private HighDiscountAgentCodeService highDiscountAgentCodeService; + + @Resource + private RedisUtil redisUtil; + + @Resource + private HuiLianTongConfig huiLianTongConfig; + + @Test + public void test(){ + try { + huiLianTongConfig.getToken(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + + public static void main(String[] args) { + + requestOrder(); + } + + public static void requestOrder(){ + + Map heard = new HashMap<>(); + heard.put("Cookie", "_ida=oArhO6XxKSvjI9wLP3cTK-iSG8yY"); + + + Map map = new HashMap<>();; + map.put("goodsId", "23423529"); + map.put("goodsType", "1"); + map.put("saleCount", "1"); + + List> orderList = new ArrayList<>(); + orderList.add(map); + + Map param = new HashMap<>(); + param.put("highChildOrderList", orderList); + + int success = 0 ; + int fail = 0; + + JSONObject object = HttpsUtils.doPost("https://hsgcs.dctpay.com/crest/highOrder/addOrder", param, heard); + if (object.getString("return_code").equals("000000")) { + success++; + System.out.println("提交订单成功"); + } else { + fail++; + System.out.println(object.getString("return_msg")); + } + + System.out.println("成功数量" + success); + System.out.println("失败数量" + fail); + + } + +} diff --git a/hai-service/src/main/java/com/hai/config/UnionUserConfig.java b/hai-service/src/main/java/com/hai/config/UnionUserConfig.java new file mode 100644 index 00000000..095c095b --- /dev/null +++ b/hai-service/src/main/java/com/hai/config/UnionUserConfig.java @@ -0,0 +1,132 @@ +package com.hai.config; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.hai.common.pay.util.sdk.WXPayConstants; +import com.hai.common.utils.HttpsUtils; +import org.apache.commons.lang3.StringUtils; + +import javax.xml.bind.DatatypeConverter; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.security.interfaces.RSAPrivateKey; +import java.security.interfaces.RSAPublicKey; +import java.util.*; + +/** + * 银联用户信息 + * @author hurui + */ +public class UnionUserConfig { + + private static String requestUrl = "https://open.95516.com/open/access/1.0/backendToken"; + private static String appId = "1900bc84497cab3b"; + private static String secret = "665193ddd44248acb461594cfe0ded5b"; + + /** + * 获取应用访问令牌backendToken + * @return + */ + public static JSONObject getBackendToken() { + Map paramMap = new HashMap<>(); + paramMap.put("appId", appId); + paramMap.put("nonceStr", createNonceStr()); + paramMap.put("timestamp", System.currentTimeMillis()); + paramMap.put("signature", generateSign(paramMap)); + return HttpsUtils.doPost(requestUrl, JSONObject.toJSONString(paramMap)); + } + + + /** + * 参数排序 + * @param param + * @return + */ + private static String paramSort(final Map param) { + Set keySet = param.keySet(); + String[] keyArray = keySet.toArray(new String[keySet.size()]); + Arrays.sort(keyArray); + StringBuilder sb = new StringBuilder(); + for (String k : keyArray) { + if (k.equals(WXPayConstants.FIELD_SIGN)) { + continue; + } + if (StringUtils.isBlank(sb.toString())) { + sb.append(k).append("=").append(param.get(k)); + } else { + sb.append("&").append(k).append("=").append(param.get(k)); + } + } + param.remove("secret"); + return sb.toString(); + } + + /** + * 生成签名 + * @param data + * @return + * @throws Exception + */ + private static String generateSign(Map data){ + data.put("secret", secret); + String sign = sha256(paramSort(data).getBytes()); + return sign; + } + + /** + * 生成随机16位随机字符串 + * @return + */ + public static String createNonceStr(){ + String sl = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; + StringBuilder sb = new StringBuilder(); + for(int i = 0 ; i < 16 ; i ++){ + sb.append(sl.charAt(new Random().nextInt(sl.length()))); + } + return sb.toString(); + } + + public static String sha256(byte[] data) { + try { + MessageDigest md = MessageDigest.getInstance("SHA-256"); + return bytesToHex(md.digest(data)); + } catch (Exception ex) { + return null; + } + } + + public static String bytesToHex(byte[] bytes) { + String hexArray = "0123456789abcdef"; + StringBuilder sb = new StringBuilder(bytes.length * 2); + for (byte b : bytes) { + int bi = b & 0xff; + sb.append(hexArray.charAt(bi >> 4)); + sb.append(hexArray.charAt(bi & 0xf)); + } + return sb.toString(); + } + + public static Map generatorRSA(){ + KeyPairGenerator keyGen = null; + try { + keyGen = KeyPairGenerator.getInstance("RSA"); + keyGen.initialize(1024); + KeyPair keyPair = keyGen.generateKeyPair(); + RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic(); + RSAPrivateKey privateKey = (RSAPrivateKey) keyPair.getPrivate(); + + String publicKeyBase64 = DatatypeConverter.printBase64Binary(publicKey.getEncoded()); + String privateKeyBase64 = DatatypeConverter.printBase64Binary(privateKey.getEncoded()); + + Map map = new HashMap<>(); + map.put("publicKey", publicKeyBase64); + map.put("privateKey", privateKeyBase64); + return map; + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + } + return null; + } +} diff --git a/hai-service/src/main/java/com/hai/dao/HighUserMapper.java b/hai-service/src/main/java/com/hai/dao/HighUserMapper.java index 080e2ff2..69ace2cb 100644 --- a/hai-service/src/main/java/com/hai/dao/HighUserMapper.java +++ b/hai-service/src/main/java/com/hai/dao/HighUserMapper.java @@ -44,15 +44,15 @@ public interface HighUserMapper extends HighUserMapperExt { "sex, birthdate, reg_time, ", "gold, `status`, open_id, ", "open_id_h5, union_id, ", - "ext_1, ext_2, ext_3, ", - "ext_4)", + "info_complete_status, ext_1, ", + "ext_2, ext_3, ext_4)", "values (#{headerImg,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, ", "#{phone,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, ", "#{sex,jdbcType=VARCHAR}, #{birthdate,jdbcType=DATE}, #{regTime,jdbcType=TIMESTAMP}, ", "#{gold,jdbcType=INTEGER}, #{status,jdbcType=INTEGER}, #{openId,jdbcType=VARCHAR}, ", "#{openIdH5,jdbcType=VARCHAR}, #{unionId,jdbcType=VARCHAR}, ", - "#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR}, ", - "#{ext4,jdbcType=VARCHAR})" + "#{infoCompleteStatus,jdbcType=INTEGER}, #{ext1,jdbcType=VARCHAR}, ", + "#{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR}, #{ext4,jdbcType=VARCHAR})" }) @Options(useGeneratedKeys=true,keyProperty="id") int insert(HighUser record); @@ -76,6 +76,7 @@ public interface HighUserMapper extends HighUserMapperExt { @Result(column="open_id", property="openId", jdbcType=JdbcType.VARCHAR), @Result(column="open_id_h5", property="openIdH5", jdbcType=JdbcType.VARCHAR), @Result(column="union_id", property="unionId", jdbcType=JdbcType.VARCHAR), + @Result(column="info_complete_status", property="infoCompleteStatus", 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), @@ -86,7 +87,7 @@ public interface HighUserMapper extends HighUserMapperExt { @Select({ "select", "id, header_img, `name`, phone, `password`, sex, birthdate, reg_time, gold, `status`, ", - "open_id, open_id_h5, union_id, ext_1, ext_2, ext_3, ext_4", + "open_id, open_id_h5, union_id, info_complete_status, ext_1, ext_2, ext_3, ext_4", "from high_user", "where id = #{id,jdbcType=BIGINT}" }) @@ -104,6 +105,7 @@ public interface HighUserMapper extends HighUserMapperExt { @Result(column="open_id", property="openId", jdbcType=JdbcType.VARCHAR), @Result(column="open_id_h5", property="openIdH5", jdbcType=JdbcType.VARCHAR), @Result(column="union_id", property="unionId", jdbcType=JdbcType.VARCHAR), + @Result(column="info_complete_status", property="infoCompleteStatus", 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), @@ -134,6 +136,7 @@ public interface HighUserMapper extends HighUserMapperExt { "open_id = #{openId,jdbcType=VARCHAR},", "open_id_h5 = #{openIdH5,jdbcType=VARCHAR},", "union_id = #{unionId,jdbcType=VARCHAR},", + "info_complete_status = #{infoCompleteStatus,jdbcType=INTEGER},", "ext_1 = #{ext1,jdbcType=VARCHAR},", "ext_2 = #{ext2,jdbcType=VARCHAR},", "ext_3 = #{ext3,jdbcType=VARCHAR},", diff --git a/hai-service/src/main/java/com/hai/dao/HighUserSqlProvider.java b/hai-service/src/main/java/com/hai/dao/HighUserSqlProvider.java index 5fdbe9a6..c10a1cd1 100644 --- a/hai-service/src/main/java/com/hai/dao/HighUserSqlProvider.java +++ b/hai-service/src/main/java/com/hai/dao/HighUserSqlProvider.java @@ -76,6 +76,10 @@ public class HighUserSqlProvider { sql.VALUES("union_id", "#{unionId,jdbcType=VARCHAR}"); } + if (record.getInfoCompleteStatus() != null) { + sql.VALUES("info_complete_status", "#{infoCompleteStatus,jdbcType=INTEGER}"); + } + if (record.getExt1() != null) { sql.VALUES("ext_1", "#{ext1,jdbcType=VARCHAR}"); } @@ -114,6 +118,7 @@ public class HighUserSqlProvider { sql.SELECT("open_id"); sql.SELECT("open_id_h5"); sql.SELECT("union_id"); + sql.SELECT("info_complete_status"); sql.SELECT("ext_1"); sql.SELECT("ext_2"); sql.SELECT("ext_3"); @@ -187,6 +192,10 @@ public class HighUserSqlProvider { sql.SET("union_id = #{record.unionId,jdbcType=VARCHAR}"); } + if (record.getInfoCompleteStatus() != null) { + sql.SET("info_complete_status = #{record.infoCompleteStatus,jdbcType=INTEGER}"); + } + if (record.getExt1() != null) { sql.SET("ext_1 = #{record.ext1,jdbcType=VARCHAR}"); } @@ -224,6 +233,7 @@ public class HighUserSqlProvider { sql.SET("open_id = #{record.openId,jdbcType=VARCHAR}"); sql.SET("open_id_h5 = #{record.openIdH5,jdbcType=VARCHAR}"); sql.SET("union_id = #{record.unionId,jdbcType=VARCHAR}"); + sql.SET("info_complete_status = #{record.infoCompleteStatus,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}"); @@ -286,6 +296,10 @@ public class HighUserSqlProvider { sql.SET("union_id = #{unionId,jdbcType=VARCHAR}"); } + if (record.getInfoCompleteStatus() != null) { + sql.SET("info_complete_status = #{infoCompleteStatus,jdbcType=INTEGER}"); + } + if (record.getExt1() != null) { sql.SET("ext_1 = #{ext1,jdbcType=VARCHAR}"); } diff --git a/hai-service/src/main/java/com/hai/entity/HighUser.java b/hai-service/src/main/java/com/hai/entity/HighUser.java index d9c40b9d..4caf07d5 100644 --- a/hai-service/src/main/java/com/hai/entity/HighUser.java +++ b/hai-service/src/main/java/com/hai/entity/HighUser.java @@ -67,9 +67,6 @@ public class HighUser extends UserModel implements Serializable { private String openId; - /** - * H5openId - */ private String openIdH5; /** @@ -77,6 +74,11 @@ public class HighUser extends UserModel implements Serializable { */ private String unionId; + /** + * 用户信息完整状态 0:完整 1:需要填写用户信息 2:需要填写手机号 + */ + private Integer infoCompleteStatus; + private String ext1; private String ext2; @@ -191,6 +193,14 @@ public class HighUser extends UserModel implements Serializable { this.unionId = unionId; } + public Integer getInfoCompleteStatus() { + return infoCompleteStatus; + } + + public void setInfoCompleteStatus(Integer infoCompleteStatus) { + this.infoCompleteStatus = infoCompleteStatus; + } + public String getExt1() { return ext1; } @@ -248,6 +258,7 @@ public class HighUser extends UserModel implements Serializable { && (this.getOpenId() == null ? other.getOpenId() == null : this.getOpenId().equals(other.getOpenId())) && (this.getOpenIdH5() == null ? other.getOpenIdH5() == null : this.getOpenIdH5().equals(other.getOpenIdH5())) && (this.getUnionId() == null ? other.getUnionId() == null : this.getUnionId().equals(other.getUnionId())) + && (this.getInfoCompleteStatus() == null ? other.getInfoCompleteStatus() == null : this.getInfoCompleteStatus().equals(other.getInfoCompleteStatus())) && (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())) @@ -271,6 +282,7 @@ public class HighUser extends UserModel implements Serializable { result = prime * result + ((getOpenId() == null) ? 0 : getOpenId().hashCode()); result = prime * result + ((getOpenIdH5() == null) ? 0 : getOpenIdH5().hashCode()); result = prime * result + ((getUnionId() == null) ? 0 : getUnionId().hashCode()); + result = prime * result + ((getInfoCompleteStatus() == null) ? 0 : getInfoCompleteStatus().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()); @@ -297,6 +309,7 @@ public class HighUser extends UserModel implements Serializable { sb.append(", openId=").append(openId); sb.append(", openIdH5=").append(openIdH5); sb.append(", unionId=").append(unionId); + sb.append(", infoCompleteStatus=").append(infoCompleteStatus); sb.append(", ext1=").append(ext1); sb.append(", ext2=").append(ext2); sb.append(", ext3=").append(ext3); @@ -305,4 +318,4 @@ public class HighUser extends UserModel implements Serializable { sb.append("]"); return sb.toString(); } -} \ No newline at end of file +} diff --git a/hai-service/src/main/java/com/hai/entity/HighUserExample.java b/hai-service/src/main/java/com/hai/entity/HighUserExample.java index 823fcc7d..0601560d 100644 --- a/hai-service/src/main/java/com/hai/entity/HighUserExample.java +++ b/hai-service/src/main/java/com/hai/entity/HighUserExample.java @@ -1012,6 +1012,66 @@ public class HighUserExample { return (Criteria) this; } + public Criteria andInfoCompleteStatusIsNull() { + addCriterion("info_complete_status is null"); + return (Criteria) this; + } + + public Criteria andInfoCompleteStatusIsNotNull() { + addCriterion("info_complete_status is not null"); + return (Criteria) this; + } + + public Criteria andInfoCompleteStatusEqualTo(Integer value) { + addCriterion("info_complete_status =", value, "infoCompleteStatus"); + return (Criteria) this; + } + + public Criteria andInfoCompleteStatusNotEqualTo(Integer value) { + addCriterion("info_complete_status <>", value, "infoCompleteStatus"); + return (Criteria) this; + } + + public Criteria andInfoCompleteStatusGreaterThan(Integer value) { + addCriterion("info_complete_status >", value, "infoCompleteStatus"); + return (Criteria) this; + } + + public Criteria andInfoCompleteStatusGreaterThanOrEqualTo(Integer value) { + addCriterion("info_complete_status >=", value, "infoCompleteStatus"); + return (Criteria) this; + } + + public Criteria andInfoCompleteStatusLessThan(Integer value) { + addCriterion("info_complete_status <", value, "infoCompleteStatus"); + return (Criteria) this; + } + + public Criteria andInfoCompleteStatusLessThanOrEqualTo(Integer value) { + addCriterion("info_complete_status <=", value, "infoCompleteStatus"); + return (Criteria) this; + } + + public Criteria andInfoCompleteStatusIn(List values) { + addCriterion("info_complete_status in", values, "infoCompleteStatus"); + return (Criteria) this; + } + + public Criteria andInfoCompleteStatusNotIn(List values) { + addCriterion("info_complete_status not in", values, "infoCompleteStatus"); + return (Criteria) this; + } + + public Criteria andInfoCompleteStatusBetween(Integer value1, Integer value2) { + addCriterion("info_complete_status between", value1, value2, "infoCompleteStatus"); + return (Criteria) this; + } + + public Criteria andInfoCompleteStatusNotBetween(Integer value1, Integer value2) { + addCriterion("info_complete_status not between", value1, value2, "infoCompleteStatus"); + return (Criteria) this; + } + public Criteria andExt1IsNull() { addCriterion("ext_1 is null"); return (Criteria) this; 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 b0aa79f6..fc733901 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 @@ -156,6 +156,14 @@ public class HighUserServiceImpl implements HighUserService { user.setName(highUser.getName()); user.setOpenId(highUser.getOpenId()); user.setUnionId(highUser.getUnionId()); + + // 用户信息完整状态 + // 0:完整 + // 1:需要填写用户信息 + // 2:需要填写手机号 + if (user.getInfoCompleteStatus() == 2) { + user.setInfoCompleteStatus(0); + } highUserMapper.updateByPrimaryKey(user); return user; }