Merge branch 'score_shop' of http://120.27.238.55:7000/r/beauty-erp into score_shop
 
	
	
	
	
	
	
		
		16 files modified
	
		
		4 files added
	
	
 
	
	
	
	
	
	
	
	
 |  |  | 
 |  |  |     private String signType = ""; | 
 |  |  |     private String paySign = ""; | 
 |  |  |      | 
 |  |  |     public BrandWCPayRequestData(String prepay_id,String appID,String paySecret){ | 
 |  |  |     public BrandWCPayRequestData(String prepay_id, String appID, String paySecret){ | 
 |  |  |         //默认必须设置 | 
 |  |  |         setAppId(appID); | 
 |  |  |         //随机字符串,不长于32 位 | 
 
 |  |  | 
 |  |  | import com.matrix.system.common.interceptor.HostInterceptor; | 
 |  |  | import com.matrix.system.shopXcx.api.tools.WxShopOrderUtil; | 
 |  |  | import org.apache.log4j.Logger; | 
 |  |  | import org.jetbrains.annotations.NotNull; | 
 |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
 |  |  | import org.springframework.beans.factory.annotation.Value; | 
 |  |  | import org.springframework.stereotype.Service; | 
 |  |  | 
 |  |  |      * @return 预支付订单返回的结果对象(该结果对象已封装),在H5页面使用该对象信息 | 
 |  |  |      * @throws Exception | 
 |  |  |      */ | 
 |  |  |     public BrandWCPayRequestData createOrder(String desc,String outTradeNo, int price, String openId,String attach) throws Exception { | 
 |  |  |     public BrandWCPayRequestData createOrder(String desc, String outTradeNo, int price, String openId, String attach) throws Exception { | 
 |  |  |         Long companyId=HostInterceptor.getCompanyId(); | 
 |  |  |         BusParameterSettings notifyUrl = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WECHARPAY_NOTIFYURL, companyId); | 
 |  |  |         return buildBrandWCPayRequestData(desc, outTradeNo, price, openId, attach, notifyUrl); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 创建充值订单 | 
 |  |  |      */ | 
 |  |  |     public BrandWCPayRequestData createRechargeOrder(String desc, String outTradeNo, int price, String openId, String attach) throws Exception { | 
 |  |  |         Long companyId=HostInterceptor.getCompanyId(); | 
 |  |  |         BusParameterSettings notifyUrl = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WECHARPAY_RECHARGE_NOTIFYURL, companyId); | 
 |  |  |         return buildBrandWCPayRequestData(desc, outTradeNo, price, openId, attach, notifyUrl); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     @NotNull | 
 |  |  |     private BrandWCPayRequestData buildBrandWCPayRequestData(String desc, String outTradeNo, int price, String openId, String attach, BusParameterSettings notifyUrl) throws Exception { | 
 |  |  |         // 创建微信支付预付接口 | 
 |  |  |         JsApiPayBusiness jsApiPayBusiness = new JsApiPayBusiness(); | 
 |  |  |         String idAddr = getIpAddr(WebUtil.getRequest()); | 
 |  |  | 
 |  |  |  | 
 |  |  |         BusParameterSettings mchID = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WECHARPAY_MCHID, companyId); | 
 |  |  |         BusParameterSettings paySecret = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WECHARPAY_SECRET, companyId); | 
 |  |  |         BusParameterSettings notifyUrl = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WECHARPAY_NOTIFYURL, companyId); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         BusParameterSettings appId = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.MINIPROGRAM_APPID, companyId); | 
 |  |  |  | 
 |  |  | 
 |  |  |             LogUtil.error("创建微信支付订单失败msg={}",result.getReturn_msg()); | 
 |  |  |             throw new GlobleException("创建微信支付订单失败,请检查程序配置"); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |     } | 
 |  |  | 	 | 
 |  |  | 	 | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     /**@Description 支付后,向微信发送请求、查询订单,看订单是否真的支付成功了 | 
 |  |  |        @date 2017年6月27日 | 
 |  |  |        @atuhor jiangyouyao | 
 
 |  |  | 
 |  |  |     public static final String ZONGDIAN = "总店"; | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     private AppConstance() { | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |      */ | 
 |  |  |     public static final String WECHARPAY_NOTIFYURL = "wecharPaynotifyUrl"; | 
 |  |  |     /** | 
 |  |  |      * 充值支付通知地址 | 
 |  |  |      */ | 
 |  |  |     public static final String WECHARPAY_RECHARGE_NOTIFYURL = "wecharpayRechargeNotifyurl"; | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 支付证书地址 | 
 |  |  |      */ | 
 |  |  |     public static final String WECHARPAY_CERTLOCAL_PATH = "certLocalPath"; | 
 
 |  |  | 
 |  |  | package com.matrix.system.hive.bean; | 
 |  |  |  | 
 |  |  | import com.baomidou.mybatisplus.annotation.TableField; | 
 |  |  | import com.fasterxml.jackson.annotation.JsonFormat; | 
 |  |  | import com.matrix.core.anotations.Extend; | 
 |  |  | import com.matrix.core.tools.DateUtil; | 
 |  |  | 
 |  |  |  */ | 
 |  |  | public class MoneyCardUse  { | 
 |  |  |  | 
 |  |  |     private static final long serialVersionUID = 1L;  | 
 |  |  |  | 
 |  |  | 	 | 
 |  |  |     private Long  id; | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     private String createBy; | 
 |  |  |  | 
 |  |  |     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | 
 |  |  |     private Date createTime; | 
 |  |  |  | 
 |  |  |     private String updateBy; | 
 |  |  |  | 
 |  |  |     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | 
 |  |  |     private Date updateTime; | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 剩余次数 | 
 |  |  |      */ | 
 |  |  |     @TableField(exist = false) | 
 |  |  |     String lastCountName; | 
 |  |  |     /** | 
 |  |  |      * 数据来源 | 
 |  |  |      */ | 
 |  |  |     @TableField(exist = false) | 
 |  |  |     String sourceName; | 
 |  |  |  | 
 |  |  |     /*vo对象************/ | 
 |  |  | 
 |  |  |     /** | 
 |  |  |      * 订单ID | 
 |  |  |      */ | 
 |  |  |     @TableField(exist = false) | 
 |  |  |     private Long  orderId; | 
 |  |  |              | 
 |  |  |      | 
 |  |  | 
 |  |  |     /** | 
 |  |  |      * 前台输入的退款金额 | 
 |  |  |      */ | 
 |  |  |     @TableField(exist = false) | 
 |  |  |     private String returnMonery; | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  | 
 |  |  |         return lastCountName; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public String getCreateBy() { | 
 |  |  |         return createBy; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public void setCreateBy(String createBy) { | 
 |  |  |         this.createBy = createBy; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public Date getCreateTime() { | 
 |  |  |         return createTime; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public void setCreateTime(Date createTime) { | 
 |  |  |         this.createTime = createTime; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public String getUpdateBy() { | 
 |  |  |         return updateBy; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public void setUpdateBy(String updateBy) { | 
 |  |  |         this.updateBy = updateBy; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public Date getUpdateTime() { | 
 |  |  |         return updateTime; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public void setUpdateTime(Date updateTime) { | 
 |  |  |         this.updateTime = updateTime; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public void setLastCountName(String lastCountName) { | 
 |  |  |         this.lastCountName = lastCountName; | 
 |  |  |     } | 
 |  |  | 
 |  |  |     /** | 
 |  |  |      * 会员信息 | 
 |  |  |      */ | 
 |  |  |     @TableField(exist = false) | 
 |  |  |     private SysVipInfo vipInfo; | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 调整说明 | 
 |  |  |      */ | 
 |  |  |     @Extend | 
 |  |  |     @TableField(exist = false) | 
 |  |  |     private String changeRemark; | 
 |  |  |  | 
 |  |  |  | 
 
 |  |  | 
 |  |  |      * 订单编号 | 
 |  |  |      */ | 
 |  |  |     private String  orderNo; | 
 |  |  | 			 | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 微信支付编号 | 
 |  |  |      */ | 
 |  |  |     private String  payNo; | 
 |  |  |  | 
 |  |  |      | 
 |  |  |     /** | 
 |  |  |      * 操作员id | 
 |  |  | 
 |  |  |     public void setTimes(Integer times) { | 
 |  |  |         this.times = times; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public String getPayNo() { | 
 |  |  |         return payNo; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public void setPayNo(String payNo) { | 
 |  |  |         this.payNo = payNo; | 
 |  |  |     } | 
 |  |  | } | 
 
| New file | 
 |  |  | 
 |  |  | package com.matrix.system.hive.dao; | 
 |  |  |  | 
 |  |  | import com.baomidou.mybatisplus.core.mapper.BaseMapper; | 
 |  |  | import com.matrix.system.hive.bean.MoneyCardUse; | 
 |  |  |  | 
 |  |  | /** | 
 |  |  |  * @description 订单表 | 
 |  |  |  */ | 
 |  |  | public interface MoneyCardUseV2Dao extends BaseMapper<MoneyCardUse> { | 
 |  |  |  | 
 |  |  |  | 
 |  |  | } | 
 
 |  |  | 
 |  |  |             ShoppingGoods goods = shoppingGoodsDao.selectById(goodsId); | 
 |  |  |             flow.setFlowContent(goods.getName() + "等" + sourceOrder.getItems().size() + "件产品"); | 
 |  |  |             // 若是退款,则取负数 | 
 |  |  |             if (SysOrder.ORDER_TYPE_REFUND == sourceOrder.getOrderType()) { | 
 |  |  |             if (SysOrder.ORDER_TYPE_REFUND== sourceOrder.getOrderType()) { | 
 |  |  |                 flow.setFlowType(SysOrderFlow.FLOW_TYPE_REFUND); | 
 |  |  |                 flow.setAmount(flow.getAmount().negate()); | 
 |  |  |                 flow.setOrderId(sourceOrder.getOldOrderId()); | 
 |  |  | 
 |  |  |         order.setRemark(cardUser.getCardName()); | 
 |  |  |         order.setStaffId(user.getSuId()); | 
 |  |  |         order.setIsCross(2 + ""); | 
 |  |  |         order.setOrderType(SysOrder.ORDER_TYPE_SEAL); | 
 |  |  |         order.setStatu(Dictionary.ORDER_STATU_YFK); | 
 |  |  |         order.setCompanyId(user.getCompanyId()); | 
 |  |  |         sysOrderDao.insert(order); | 
 
 |  |  | 
 |  |  | import com.matrix.system.common.bean.BusParameterSettings; | 
 |  |  | import com.matrix.system.common.constance.AppConstance; | 
 |  |  | import com.matrix.system.common.dao.BusParameterSettingsDao; | 
 |  |  | import com.matrix.system.hive.bean.MoneyCardUse; | 
 |  |  | import com.matrix.system.hive.bean.MoneyCardUseFlow; | 
 |  |  | import com.matrix.system.hive.bean.SysVipInfo; | 
 |  |  | import com.matrix.system.hive.dao.MoneyCardUseDao; | 
 |  |  | import com.matrix.system.hive.dao.MoneyCardUseFlowDao; | 
 |  |  | import com.matrix.system.hive.dao.SysVipInfoDao; | 
 |  |  | import com.matrix.system.score.entity.ScoreVipDetail; | 
 |  |  | import com.matrix.system.score.service.ScoreVipDetailService; | 
 |  |  | import com.matrix.system.shopXcx.bean.ShopActivitiesGroupJoin; | 
 |  |  | import com.matrix.system.shopXcx.bean.ShopActivitiesGroupJoinUser; | 
 |  |  | 
 |  |  |     private String evn; | 
 |  |  |     /** | 
 |  |  |      * 微信支付回调接口 | 
 |  |  |      * | 
 |  |  |      * @param response | 
 |  |  |      * @param request | 
 |  |  |      * @throws IOException | 
 |  |  |      * @throws Exception | 
 |  |  |      */ | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     @RequestMapping(value = "/wxapi/wxpayCallback") | 
 |  |  | 
 |  |  |                             resXml = AppConstance.RESULT_XML_SUCCESS; | 
 |  |  |  | 
 |  |  |                             //支付记录 | 
 |  |  |                             recordPayLog(Integer.valueOf(orderId), payMoney, order, payLog, "支付成功", ShopOrder.ORDER_PAY_STATUS_SUCCESS); | 
 |  |  |                             recordPayLog(Integer.valueOf(orderId), 1, order.getOrderNo(), payMoney,  payLog, "支付成功", ShopOrder.ORDER_PAY_STATUS_SUCCESS); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |                         } else { | 
 |  |  | 
 |  |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     private void recordPayLog(Integer orderId, BigDecimal payMoney, ShopOrder order, ShopPayLog payLog, String payRemark, int payStatus) { | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     MoneyCardUseFlowDao moneyCardUseFlowDao; | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     MoneyCardUseDao moneyCardUseDao; | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 微信充值回调 | 
 |  |  |      */ | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     @RequestMapping(value = "/wxapi/rechargeCallBack") | 
 |  |  |     public void rechargeCallBack(HttpServletResponse response, HttpServletRequest request) throws IOException { | 
 |  |  |         LogUtil.info("微信充值回调start...."); | 
 |  |  |  | 
 |  |  |         // 获取输入参数 | 
 |  |  |         String inputLine; | 
 |  |  |         StringBuffer notityXml = new StringBuffer(); | 
 |  |  |         String resXml = ""; | 
 |  |  |         String moneyCardUseFlowId = ""; | 
 |  |  |  | 
 |  |  |         AjaxResult threadResult = new AjaxResult(AjaxResult.STATUS_SUCCESS, ""); | 
 |  |  |         try { | 
 |  |  |             while ((inputLine = request.getReader().readLine()) != null) { | 
 |  |  |                 notityXml.append(inputLine); | 
 |  |  |             } | 
 |  |  |             request.getReader().close(); | 
 |  |  |             LogUtil.info("notityXml ---- :{} ", notityXml); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |             // XMl转对象 | 
 |  |  |             Object bb = Util.getObjectFromXML(notityXml.toString(), NotifyData.class); | 
 |  |  |             NotifyData    data = new NotifyData(); | 
 |  |  |             BeanUtils.copyProperties(bb,data); | 
 |  |  |             LogUtil.info("----return_code = {}", data.getReturn_code()); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |             // 返回状态码 SUCCESS/FAIL | 
 |  |  |             if (AppConstance.CODE_SUCCESS.equals(data.getReturn_code())) { | 
 |  |  |  | 
 |  |  |                 moneyCardUseFlowId = data.getAttach(); | 
 |  |  |                 // 检验订单状态 | 
 |  |  |                 MoneyCardUseFlow moneyCardUseFlow = moneyCardUseFlowDao.selectById(Long.valueOf(moneyCardUseFlowId)); | 
 |  |  |                 SysVipInfo user=sysVipInfoDao.selectById(moneyCardUseFlow.getVipId()); | 
 |  |  |  | 
 |  |  |                 // 校验签名 | 
 |  |  |                 BusParameterSettings paySecret = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WECHARPAY_SECRET, user.getCompanyId()); | 
 |  |  |                 if (Signature.checkIsSignValidFromResponseString(notityXml.toString(),paySecret.getParamValue())) { | 
 |  |  |                     // 校验业务结果 | 
 |  |  |                     if (AppConstance.CODE_SUCCESS.equals(data.getResult_code())) { | 
 |  |  |                         // 返回SUCCESS报文 | 
 |  |  |                         resXml = AppConstance.RESULT_XML_SUCCESS; | 
 |  |  |                         // 支付费用 | 
 |  |  |                         Double total_fee = Double.parseDouble(data.getTotal_fee()); | 
 |  |  |                         // 商户订单号 | 
 |  |  |                         String payNum = data.getOut_trade_no(); | 
 |  |  |  | 
 |  |  |                         LogUtil.info("支付回调关键信息---total_fee:{},payNum:{},moneyCardUseFlowId:{}", total_fee, payNum, moneyCardUseFlowId); | 
 |  |  |                         // 订单ID | 
 |  |  |                         Double payMoney = new BigDecimal(total_fee).divide(new BigDecimal(100), 2, | 
 |  |  |                                 BigDecimal.ROUND_HALF_DOWN).doubleValue(); | 
 |  |  |  | 
 |  |  |                         if (moneyCardUseFlow.getCarUseId()==null) { | 
 |  |  |                             ShopPayLog payLog = new ShopPayLog(); | 
 |  |  |                             if(payMoney==moneyCardUseFlow.getTotal()){ | 
 |  |  |                                 threadResult.putInMap("status", "success"); | 
 |  |  |                                 resXml = AppConstance.RESULT_XML_SUCCESS; | 
 |  |  |                                 MoneyCardUse moneyCardUse = moneyCardUseDao.selectVipCard(user.getId()); | 
 |  |  |                                 moneyCardUseFlow.setCarUseId(moneyCardUse.getId()); | 
 |  |  |                                 moneyCardUseFlow.setCardName(moneyCardUse.getCardName()); | 
 |  |  |                                 moneyCardUseFlow.setBalance(moneyCardUse.getGiftMoney() + moneyCardUse.getRealMoney()); | 
 |  |  |                                 moneyCardUseFlowDao.update(moneyCardUseFlow); | 
 |  |  |                                 //充值记录 | 
 |  |  |                                 recordPayLog(Integer.valueOf(moneyCardUseFlowId),2,moneyCardUseFlow.getPayNo(),new BigDecimal(payMoney),  payLog, "充值成功", ShopOrder.ORDER_PAY_STATUS_SUCCESS); | 
 |  |  |                             }else{ | 
 |  |  |                                 LogUtil.debug("支付金额不一致,检查支付金额payMoney={},order.getPayMoney()={}", payMoney, moneyCardUseFlow.getTotal()); | 
 |  |  |                                 threadResult.putInMap("status", "err"); | 
 |  |  |                                 threadResult.putInMap("msg", "支付金额不一致"); | 
 |  |  |                                 resXml = AppConstance.RESULT_XML_FAIL.replace(ERRORMSG, "微信标识业务是失败"); | 
 |  |  |                             } | 
 |  |  |  | 
 |  |  |                         } else { | 
 |  |  |                             LogUtil.info("充值已经确认"); | 
 |  |  |                         } | 
 |  |  |  | 
 |  |  |                     } else { | 
 |  |  |                         LogUtil.info("微信标识业务是失败"); | 
 |  |  |                         threadResult.putInMap("status", "err"); | 
 |  |  |                         threadResult.putInMap("msg", "查询支付信息失败,请联系客服或者刷新支付信息(错误码:001)"); | 
 |  |  |                         resXml = AppConstance.RESULT_XML_FAIL.replace(ERRORMSG, "微信标识业务是失败"); | 
 |  |  |                     } | 
 |  |  |                 } else { | 
 |  |  |                     LogUtil.info("无效签名"); | 
 |  |  |                     threadResult.putInMap("status", "err"); | 
 |  |  |                     threadResult.putInMap("msg", "查询支付信息失败,请联系客服或者刷新支付信息(错误码:002)"); | 
 |  |  |                     resXml = AppConstance.RESULT_XML_FAIL.replace(ERRORMSG, "微信标识业务是失败"); | 
 |  |  |                 } | 
 |  |  |             } else { | 
 |  |  |                 LogUtil.info("通信标识失败"); | 
 |  |  |                 threadResult.putInMap("status", "err"); | 
 |  |  |                 threadResult.putInMap("msg", "查询支付信息失败,请联系客服或者刷新支付信息(错误码:003)"); | 
 |  |  |                 resXml = AppConstance.RESULT_XML_FAIL.replace(ERRORMSG, "通信标识失败"); | 
 |  |  |             } | 
 |  |  |         } catch (Exception e) { | 
 |  |  |             LogUtil.error("支付回调签名错误", e); | 
 |  |  |             threadResult.putInMap("status", "err"); | 
 |  |  |             threadResult.putInMap("msg", "查询支付信息失败,请联系客服或者刷新支付信息(错误码:004)"); | 
 |  |  |             resXml = AppConstance.RESULT_XML_FAIL.replace(ERRORMSG, "支付回调签名错误"); | 
 |  |  |         } finally { | 
 |  |  |             // 通知线程消息 | 
 |  |  |             PayThreadPool.notifyThread(Integer.valueOf(moneyCardUseFlowId), threadResult); | 
 |  |  |             sendResultBack(response, resXml); | 
 |  |  |         } | 
 |  |  |         return; | 
 |  |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     private void recordPayLog(Integer orderId, Integer type,String orderNo, BigDecimal payMoney, ShopPayLog payLog, String payRemark, int payStatus) { | 
 |  |  |         //设置支付类型为收款 | 
 |  |  |         payLog.setPayType(1); | 
 |  |  |         payLog.setPayType(type); | 
 |  |  |         payLog.setJoinId(orderId); | 
 |  |  |         payLog.setPayMoney(payMoney); | 
 |  |  |         payLog.setPayOrderNo(order.getOrderNo()); | 
 |  |  |         payLog.setPayOrderNo(orderNo); | 
 |  |  |         payLog.setPayRemark(payRemark); | 
 |  |  |         payLog.setPayStatus(payStatus); | 
 |  |  |         payLog.setCreateBy(AppConstance.SYSTEM_USER); | 
 
| New file | 
 |  |  | 
 |  |  | package com.matrix.system.shopXcx.api.action; | 
 |  |  |  | 
 |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
 |  |  | import com.baomidou.mybatisplus.core.metadata.IPage; | 
 |  |  | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
 |  |  | import com.matrix.component.redis.RedisUserLoginUtils; | 
 |  |  | import com.matrix.component.wechat.externalInterface.protocol.paramProtocol.BrandWCPayRequestData; | 
 |  |  | import com.matrix.component.wechat.externalInterface.weixinUtil.WeixinServiceUtil; | 
 |  |  | import com.matrix.core.pojo.AjaxResult; | 
 |  |  | import com.matrix.core.pojo.BasePageQueryDto; | 
 |  |  | import com.matrix.core.pojo.PaginationVO; | 
 |  |  | import com.matrix.core.tools.LogUtil; | 
 |  |  | import com.matrix.core.tools.StringUtils; | 
 |  |  | import com.matrix.system.hive.bean.MoneyCardUse; | 
 |  |  | import com.matrix.system.hive.bean.MoneyCardUseFlow; | 
 |  |  | import com.matrix.system.hive.bean.SysVipInfo; | 
 |  |  | import com.matrix.system.hive.dao.MoneyCardUseFlowDao; | 
 |  |  | import com.matrix.system.hive.dao.MoneyCardUseV2Dao; | 
 |  |  | import com.matrix.system.hive.service.CodeService; | 
 |  |  | import com.matrix.system.shopXcx.api.vo.WxMoneyCardUseVO; | 
 |  |  | import io.swagger.annotations.Api; | 
 |  |  | import io.swagger.annotations.ApiOperation; | 
 |  |  | import io.swagger.annotations.ApiResponse; | 
 |  |  | import io.swagger.annotations.ApiResponses; | 
 |  |  | import org.springframework.beans.BeanUtils; | 
 |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
 |  |  | import org.springframework.validation.annotation.Validated; | 
 |  |  | import org.springframework.web.bind.annotation.*; | 
 |  |  |  | 
 |  |  | import java.math.BigDecimal; | 
 |  |  | import java.util.Date; | 
 |  |  | import java.util.List; | 
 |  |  | import java.util.Map; | 
 |  |  | import java.util.stream.Collectors; | 
 |  |  |  | 
 |  |  | /** | 
 |  |  |  * @author jyy | 
 |  |  |  * @date 2021-04-09 | 
 |  |  |  **/ | 
 |  |  | @Api(tags = "会员储值卡") | 
 |  |  | @RestController | 
 |  |  | @RequestMapping(value = "/wxapi/moneyCardUse") | 
 |  |  | public class WxMoneyCardUseAction { | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     WeixinServiceUtil weixinServiceUtil; | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private MoneyCardUseV2Dao moneyCardUseV2Dao; | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private RedisUserLoginUtils redisUserLoginUtils; | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     MoneyCardUseFlowDao moneyCardUseFlowDao; | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     CodeService codeService; | 
 |  |  |  | 
 |  |  |     @ApiOperation(value = "查询会员储值卡", notes = "") | 
 |  |  |     @GetMapping(value = "/getUserMoneyCardUseList") | 
 |  |  |     @ApiResponses({ | 
 |  |  |             @ApiResponse(code = 200, message = "ok", response = WxMoneyCardUseVO.class) | 
 |  |  |     }) | 
 |  |  |     public AjaxResult getUserMoneyCardUseList(@RequestBody @Validated BasePageQueryDto pageDto) { | 
 |  |  |         SysVipInfo sysVipInfo = redisUserLoginUtils.getLoginUser(SysVipInfo.class); | 
 |  |  |         QueryWrapper queryWrapper = new QueryWrapper(); | 
 |  |  |         queryWrapper.eq("vip_id", sysVipInfo.getId()); | 
 |  |  |         IPage<MoneyCardUse> page = new Page<>(pageDto.getPageNum(), pageDto.getPageSize()); | 
 |  |  |         IPage pageList = moneyCardUseV2Dao.selectPage(page, queryWrapper); | 
 |  |  |         List<WxMoneyCardUseVO> rows = (List<WxMoneyCardUseVO>) pageList.getRecords().stream().map(item -> { | 
 |  |  |             WxMoneyCardUseVO vo = new WxMoneyCardUseVO(); | 
 |  |  |             BeanUtils.copyProperties(item, vo); | 
 |  |  |             return vo; | 
 |  |  |         }).collect(Collectors.toList()); | 
 |  |  |         return AjaxResult.buildSuccessInstance(rows); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @ApiOperation(value = "创建储值卡充值预付单", notes = "传入参数 {rechargeAmount:10} 最少充值1元,最多2位小数 ") | 
 |  |  |     @PostMapping(value = "/createRechargeOrder") | 
 |  |  |     @ApiResponses({ | 
 |  |  |             @ApiResponse(code = 200, message = "ok", response = AjaxResult.class) | 
 |  |  |     }) | 
 |  |  |     public AjaxResult createRechargeOrder(@RequestBody Map<String, String> param) throws Exception { | 
 |  |  |  | 
 |  |  |         String rechargeAmount = param.get("rechargeAmount"); | 
 |  |  |         if (StringUtils.isBlank(rechargeAmount)) { | 
 |  |  |             return AjaxResult.buildFailInstance("去输入充值金额"); | 
 |  |  |         } | 
 |  |  |         double total = new BigDecimal(rechargeAmount).setScale(2, BigDecimal.ROUND_HALF_DOWN).doubleValue(); | 
 |  |  |         if (total < 0.02) { | 
 |  |  |             return AjaxResult.buildFailInstance("充值金额最底1元"); | 
 |  |  |         } | 
 |  |  |         SysVipInfo sysVipInfo = redisUserLoginUtils.getLoginUser(SysVipInfo.class); | 
 |  |  |         MoneyCardUseFlow moneyCardUseFlow = new MoneyCardUseFlow(); | 
 |  |  |         moneyCardUseFlow.setVipId(sysVipInfo.getId()); | 
 |  |  |         moneyCardUseFlow.setPayNo(codeService.get32LenNumberCode()); | 
 |  |  |         moneyCardUseFlow.setTotal(total); | 
 |  |  |         moneyCardUseFlow.setCreateTime(new Date()); | 
 |  |  |         moneyCardUseFlow.setType(MoneyCardUseFlow.USE_TYPE_CZ); | 
 |  |  |         moneyCardUseFlowDao.insert(moneyCardUseFlow); | 
 |  |  |         moneyCardUseFlow.setContent("微信充值"); | 
 |  |  |         BrandWCPayRequestData payData = weixinServiceUtil.createRechargeOrder("储值卡充值", moneyCardUseFlow.getPayNo(), | 
 |  |  |                 (int) (moneyCardUseFlow.getTotal() * 100), sysVipInfo.getOpenId(), String.valueOf(moneyCardUseFlow.getId())); | 
 |  |  |         AjaxResult result = AjaxResult.buildSuccessInstance(payData); | 
 |  |  |         result.putInMap("orderId", moneyCardUseFlow.getId()); | 
 |  |  |         return result; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @ApiOperation(value = "查询充值结果", notes = " ") | 
 |  |  |     @GetMapping(value = "/getRechargePayStatus/{orderId}") | 
 |  |  |     @ApiResponses({ | 
 |  |  |             @ApiResponse(code = 200, message = "ok", response = AjaxResult.class) | 
 |  |  |     }) | 
 |  |  |     public AjaxResult getRechargePayStatus(@PathVariable Long orderId) { | 
 |  |  |         AjaxResult result =AjaxResult.buildSuccessInstance("查询成功"); | 
 |  |  |         MoneyCardUseFlow moneyCardUseFlow = moneyCardUseFlowDao.selectById(orderId); | 
 |  |  |         if (moneyCardUseFlow.getCarUseId() != null) { | 
 |  |  |             result.putInMap("status", "success"); | 
 |  |  |             result.putInMap("msg", "支付成功"); | 
 |  |  |         } else { | 
 |  |  |             LogUtil.debug("充值等待支付中={}。。。", orderId); | 
 |  |  |             PayThreadPool.waitThread(orderId.intValue(), new Object()); | 
 |  |  |             result = PayThreadPool.getThreadResult(orderId.intValue()); | 
 |  |  |             LogUtil.debug("充值订单支付完成={}。。。", orderId); | 
 |  |  |         } | 
 |  |  |         return result; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     @ApiOperation(value = "查询会员储值卡充值使用记录", notes = "keywords 传入会员卡ID") | 
 |  |  |     @GetMapping(value = "/getRechargeList") | 
 |  |  |     @ApiResponses({ | 
 |  |  |             @ApiResponse(code = 200, message = "ok", response = MoneyCardUseFlow.class) | 
 |  |  |     }) | 
 |  |  |     public AjaxResult getRechargeList(@RequestBody @Validated BasePageQueryDto pageDto) { | 
 |  |  |         if(StringUtils.isBlank(pageDto.getKeywords())){ | 
 |  |  |             return AjaxResult.buildFailInstance("keywords参数是必须的"); | 
 |  |  |         } | 
 |  |  |         PaginationVO pageVo = new PaginationVO(); | 
 |  |  |         pageVo.setOffset((pageDto.getPageNum() - 1) * pageDto.getPageSize()); | 
 |  |  |         pageVo.setLimit(pageDto.getPageSize()); | 
 |  |  |         SysVipInfo sysVipInfo = redisUserLoginUtils.getLoginUser(SysVipInfo.class); | 
 |  |  |         MoneyCardUseFlow moneyCardUseFlow=new MoneyCardUseFlow(); | 
 |  |  |         moneyCardUseFlow.setVipId(sysVipInfo.getId()); | 
 |  |  |         moneyCardUseFlow.setCarUseId(Long.parseLong(pageDto.getKeywords())); | 
 |  |  |         List<MoneyCardUseFlow> dataList = moneyCardUseFlowDao.selectInPage(moneyCardUseFlow, pageVo); | 
 |  |  |         return AjaxResult.buildSuccessInstance(dataList, moneyCardUseFlowDao.selectTotalRecord(moneyCardUseFlow)); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  | } | 
 
 |  |  | 
 |  |  | import com.matrix.system.fenxiao.entity.ShopSalesmanApply; | 
 |  |  | import com.matrix.system.fenxiao.service.ShopSalesmanApplyService; | 
 |  |  | import com.matrix.system.hive.bean.SysVipInfo; | 
 |  |  | import com.matrix.system.hive.dao.MoneyCardUseDao; | 
 |  |  | import com.matrix.system.hive.dao.SysVipInfoDao; | 
 |  |  | import com.matrix.system.hive.service.SysVipInfoService; | 
 |  |  | import com.matrix.system.score.dao.ScoreVipDetailDao; | 
 |  |  | import com.matrix.system.shopXcx.api.WeChatApiTools; | 
 |  |  | import com.matrix.system.shopXcx.api.dto.XcxUserSaveUserInfoDto; | 
 |  |  | import com.matrix.system.shopXcx.dao.ShopCouponRecordDao; | 
 |  |  | import net.sf.json.JSONObject; | 
 |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
 |  |  | import org.springframework.beans.factory.annotation.Value; | 
 |  |  | 
 |  |  |     @Autowired | 
 |  |  |     WeChatApiTools weChatApiTools; | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private ScoreVipDetailDao scoreVipDetailDao; | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private MoneyCardUseDao moneyCardUseDao; | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private WeixinServiceUtil weixinServiceUtil; | 
 |  |  | 
 |  |  |         return res; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     ShopCouponRecordDao shopCouponRecordDao; | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 查询用户信息 | 
 |  |  |      */ | 
 |  |  | 
 |  |  |     public @ResponseBody | 
 |  |  |     AjaxResult findUserInfo() { | 
 |  |  |         SysVipInfo loginUser = redisUserLoginUtils.getLoginUser(SysVipInfo.class); | 
 |  |  |         String openId = loginUser.getOpenId(); | 
 |  |  |         SysVipInfo sysVipInfo = sysVipInfoService.findByOpenId(openId); | 
 |  |  |         SysVipInfo sysVipInfo = sysVipInfoService.findById(loginUser.getId()); | 
 |  |  |         sysVipInfo.setPointAll(scoreVipDetailDao.selectUserTotalScore(loginUser.getId())); | 
 |  |  |         sysVipInfo.setBalance(moneyCardUseDao.selectVipCardTotalMoney(loginUser.getId())); | 
 |  |  |         AjaxResult res = new AjaxResult(); | 
 |  |  |         res.putInMap("couponCount", shopCouponRecordDao.countUnuseCouponRecord(loginUser.getId())); | 
 |  |  |         res.putInMap("prizeCount",0); | 
 |  |  |         res.putInMap("userInfo", sysVipInfo); | 
 |  |  |         res.setStatus(AjaxResult.STATUS_SUCCESS); | 
 |  |  |         return res; | 
 
 |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 领取优惠券 | 
 |  |  |      * | 
 |  |  |      * | 
 |  |  |      * @param couponId | 
 |  |  |      * @return | 
 
| New file | 
 |  |  | 
 |  |  | package com.matrix.system.shopXcx.api.vo; | 
 |  |  |  | 
 |  |  | import com.fasterxml.jackson.annotation.JsonFormat; | 
 |  |  | import com.matrix.core.tools.DateUtil; | 
 |  |  | import io.swagger.annotations.ApiModel; | 
 |  |  | import io.swagger.annotations.ApiModelProperty; | 
 |  |  | import lombok.Data; | 
 |  |  | import org.springframework.format.annotation.DateTimeFormat; | 
 |  |  |  | 
 |  |  | import java.util.Date; | 
 |  |  |  | 
 |  |  | /** | 
 |  |  |  * @author jyy | 
 |  |  |  * @date 2020-04-21 11:36 | 
 |  |  |  **/ | 
 |  |  | @Data | 
 |  |  | @ApiModel(value = "WxMoneyCardUseVO", description = "储值卡展示类") | 
 |  |  | public class WxMoneyCardUseVO   { | 
 |  |  |  | 
 |  |  |     @ApiModelProperty(value ="储值卡ID") | 
 |  |  |     private Long  id; | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     @ApiModelProperty(value ="储值卡名称") | 
 |  |  |     private String cardName; | 
 |  |  |  | 
 |  |  |     @ApiModelProperty(value ="失效时间") | 
 |  |  |     @JsonFormat(pattern = DateUtil.DATE_FORMAT_DD, timezone = "GMT+8") | 
 |  |  |     @DateTimeFormat(pattern= DateUtil.DATE_FORMAT_DD) | 
 |  |  |     private Date failTime; | 
 |  |  |  | 
 |  |  |     @ApiModelProperty(value ="状态,有效,无效,转让,冻结,退款") | 
 |  |  |     private String  status; | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     @ApiModelProperty(value ="总次数") | 
 |  |  |     private Integer  useTotal; | 
 |  |  |  | 
 |  |  |     @ApiModelProperty(value ="剩余次数") | 
 |  |  |     private Integer  lastCount; | 
 |  |  |  | 
 |  |  |     @ApiModelProperty(value ="来源,购买,转让,赠送") | 
 |  |  |     private String  source; | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     @ApiModelProperty(value ="本金") | 
 |  |  |     private Double  realMoney; | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     @ApiModelProperty(value ="赠送金额") | 
 |  |  |     private Double  giftMoney; | 
 |  |  |  | 
 |  |  |     @ApiModelProperty(value ="是会籍卡? Y 是,N否") | 
 |  |  |     private String  isVipCar; | 
 |  |  |  | 
 |  |  | } | 
 
 |  |  | 
 |  |  |     public List<ShopCoupon> selectHdListByProductId(@Param("productId") Integer productId, @Param("attrIds") List<String> attrIds, @Param("companyId")Long companyId); | 
 |  |  |  | 
 |  |  |     ShopCoupon getCouponByTitle(@Param("title")String title, @Param("companyId")Long companyId); | 
 |  |  |  | 
 |  |  | } | 
 
 |  |  | 
 |  |  |  | 
 |  |  |     List<CouponReceiveInfoVO> selectMyPastCoupon(@Param("companyId")Long shopId, @Param("userId") Long userId, @Param("pageVo") PaginationVO pageVo); | 
 |  |  |  | 
 |  |  |     int countUnuseCouponRecord(Long id); | 
 |  |  | } | 
 
 |  |  | 
 |  |  | ADD COLUMN `self_commission`  double(20,2) NULL COMMENT '自购返佣比例%' AFTER `company_id`; | 
 |  |  |  | 
 |  |  |  | 
 |  |  | ALTER TABLE `money_card_use_flow` | 
 |  |  | ADD COLUMN `pay_no`  varchar(32) NULL COMMENT '微信充值订单号'; | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  | ALTER TABLE `sys_vip_info` | 
 |  |  |     ADD COLUMN `fenxiao_state` int(11) NULL DEFAULT NULL COMMENT '分销审核状态' AFTER `recommend_id`, | 
 
 |  |  | 
 |  |  |     <resultMap type="com.matrix.system.hive.bean.MoneyCardUseFlow" id="MoneyCardUseFlowMap"> | 
 |  |  |         <id property="id" column="id" /> | 
 |  |  |         <result property="orderNo" column="order_no" /> | 
 |  |  |         <result property="payNo" column="pay_no" /> | 
 |  |  |         <result property="operationId" column="operation_id" /> | 
 |  |  |         <result property="content" column="content" /> | 
 |  |  |         <result property="createTime" column="create_time" /> | 
 |  |  | 
 |  |  |     <resultMap type="com.matrix.system.hive.bean.MoneyCardUseFlow" id="MoneyCardUseFlowSimpleMap"> | 
 |  |  |         <id property="id" column="id" /> | 
 |  |  |         <result property="orderNo" column="order_no" /> | 
 |  |  |         <result property="payNo" column="pay_no" /> | 
 |  |  |         <result property="operationId" column="operation_id" /> | 
 |  |  |         <result property="content" column="content" /> | 
 |  |  |         <result property="createTime" column="create_time" /> | 
 |  |  | 
 |  |  |         INSERT INTO money_card_use_flow ( | 
 |  |  |         id, | 
 |  |  |         order_no, | 
 |  |  |         pay_no, | 
 |  |  |         operation_id, | 
 |  |  |         content, | 
 |  |  |         create_time, | 
 |  |  | 
 |  |  |         VALUES ( | 
 |  |  |         #{id}, | 
 |  |  |         #{orderNo}, | 
 |  |  |         #{payNo}, | 
 |  |  |         #{operationId}, | 
 |  |  |         #{content}, | 
 |  |  |         #{createTime}, | 
 |  |  | 
 |  |  |         select | 
 |  |  |         id, | 
 |  |  |         order_no, | 
 |  |  |         pay_no, | 
 |  |  |         operation_id, | 
 |  |  |         content, | 
 |  |  |         create_time, | 
 |  |  | 
 |  |  |             </if> | 
 |  |  |             <if test="record.orderNo != null and record.orderNo !='' "> | 
 |  |  |                 and order_no = #{record.orderNo} | 
 |  |  |             </if> | 
 |  |  |             <if test="record.payNo != null and record.payNo !='' "> | 
 |  |  |                 and pay_no = #{record.payNo} | 
 |  |  |             </if> | 
 |  |  |             <if test="record.operationId != null and record.operationId !='' "> | 
 |  |  |                 and operation_id = #{record.operationId} | 
 |  |  | 
 |  |  |             <if test="record.orderNo != null and record.orderNo !='' "> | 
 |  |  |                 and order_no = #{record.orderNo} | 
 |  |  |             </if> | 
 |  |  |             <if test="record.payNo != null and record.payNo !='' "> | 
 |  |  |                 and pay_no = #{record.payNo} | 
 |  |  |             </if> | 
 |  |  |             <if test="record.operationId != null and record.operationId !='' "> | 
 |  |  |                 and operation_id = #{record.operationId} | 
 |  |  |             </if> | 
 |  |  | 
 |  |  |         select | 
 |  |  |         id, | 
 |  |  |         order_no, | 
 |  |  |         pay_no, | 
 |  |  |         operation_id, | 
 |  |  |         content, | 
 |  |  |         create_time, | 
 |  |  | 
 |  |  |         select | 
 |  |  |         id, | 
 |  |  |         order_no, | 
 |  |  |         pay_no, | 
 |  |  |         operation_id, | 
 |  |  |         content, | 
 |  |  |         create_time, | 
 |  |  | 
 |  |  |             <if test="record.orderNo != null and record.orderNo !='' "> | 
 |  |  |                 and order_no = #{record.orderNo} | 
 |  |  |             </if> | 
 |  |  |             <if test="record.payNo != null and record.payNo !='' "> | 
 |  |  |                 and pay_no = #{record.payNo} | 
 |  |  |             </if> | 
 |  |  |             <if test="record.operationId != null and record.operationId !='' "> | 
 |  |  |                 and operation_id = #{record.operationId} | 
 |  |  |             </if> | 
 
| New file | 
 |  |  | 
 |  |  | <?xml version="1.0" encoding="UTF-8"?> | 
 |  |  | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | 
 |  |  |         "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | 
 |  |  |  | 
 |  |  | <mapper namespace="com.matrix.system.hive.dao.MoneyCardUseV2Dao"> | 
 |  |  |  | 
 |  |  | </mapper> | 
 
 |  |  | 
 |  |  |         </if> | 
 |  |  |     </select> | 
 |  |  |  | 
 |  |  |     <select id="countUnuseCouponRecord" resultType="java.lang.Integer"> | 
 |  |  |         select  count(*) from shop_coupon_record where user_id = #{userId} and   is_using = 2 | 
 |  |  |     </select> | 
 |  |  |  | 
 |  |  | </mapper> | 
 
 |  |  | 
 |  |  |                 console.log("您的浏览器支持WebSocket"); | 
 |  |  |                 //实现化WebSocket对象,指定要连接的服务器地址与端口  建立连接 | 
 |  |  |  | 
 |  |  |                 var socketUrl="ws://localhost:8080/webSocketServer?userId=123"; | 
 |  |  |                 //var socketUrl="ws://test.hive.jyymatrix.cc/webSocketServer?userId=123"; | 
 |  |  |                 var socketUrl="ws://192.168.0.6:8080/webSocketServer?userId=123"; | 
 |  |  |                 console.log(socketUrl); | 
 |  |  |                 if(socket!=null){ | 
 |  |  |                     socket.close(); | 
 
 |  |  | 
 |  |  |         newSetting2.setCategory("仓库设置"); | 
 |  |  |         newSettings.add(newSetting2); | 
 |  |  |  | 
 |  |  |         ParameterSettings newSetting3=new ParameterSettings(); | 
 |  |  |         newSetting3.setCode(AppConstance.WECHARPAY_RECHARGE_NOTIFYURL); | 
 |  |  |         newSetting3.setName("储值卡充值回调地址"); | 
 |  |  |         newSetting3.setType(1); | 
 |  |  |         newSetting3.setCategory("微信开发配置"); | 
 |  |  |         newSettings.add(newSetting3); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  |