| @@ -0,0 +1,8 @@ | |||||
| ALTER TABLE `wx_pay_account` | |||||
| ADD COLUMN `sub_app_id` varchar(50) COMMENT '服务商模式下的子商户公众账号ID' AFTER `sub_mch_id`, | |||||
| ADD COLUMN `service_id` varchar(50) COMMENT '微信支付分serviceId' AFTER `real_rate`, | |||||
| ADD COLUMN `pay_score_notify_url` varchar(255) COMMENT '微信支付分回调地址' AFTER `service_id`, | |||||
| ADD COLUMN `api_v3_key` varchar(255) COMMENT 'apiV3秘钥' AFTER `pay_score_notify_url`, | |||||
| ADD COLUMN `cert_serial_no` varchar(255) COMMENT '证书序列号' AFTER `api_v3_key`, | |||||
| ADD COLUMN `private_key_path` varchar(255) COMMENT 'apiv3 商户apiclient_key.pem 商户私钥' AFTER `cert_serial_no`, | |||||
| ADD COLUMN `private_cert_path` varchar(255) COMMENT 'apiv3 商户apiclient_cert.pem' AFTER `private_key_path`; | |||||
| @@ -107,7 +107,9 @@ public class ShiroConfig { | |||||
| // callback | // callback | ||||
| filterChainDefinitionMap.put("/wxPay/notify/**", "anon"); // 支付回调 | filterChainDefinitionMap.put("/wxPay/notify/**", "anon"); // 支付回调 | ||||
| filterChainDefinitionMap.put("/wxPayBill/notify/**", "anon"); | filterChainDefinitionMap.put("/wxPayBill/notify/**", "anon"); | ||||
| filterChainDefinitionMap.put("/wxBusiness/**", "anon"); // 商圈回调 | |||||
| filterChainDefinitionMap.put("/alipay/notify/**", "anon"); | filterChainDefinitionMap.put("/alipay/notify/**", "anon"); | ||||
| filterChainDefinitionMap.put("/wxMsgCallback/**", "anon"); | filterChainDefinitionMap.put("/wxMsgCallback/**", "anon"); | ||||
| @@ -1,14 +1,28 @@ | |||||
| package com.iformall.controller.callback; | package com.iformall.controller.callback; | ||||
| import com.github.binarywang.wxpay.bean.businesscircle.BusinessCircleNotifyData; | |||||
| import com.github.binarywang.wxpay.bean.businesscircle.PaidResult; | |||||
| import com.github.binarywang.wxpay.bean.businesscircle.RefundResult; | |||||
| import com.github.binarywang.wxpay.bean.ecommerce.SignatureHeader; | |||||
| import com.github.binarywang.wxpay.exception.WxPayException; | |||||
| import com.github.binarywang.wxpay.service.WxPayService; | |||||
| import com.iformall.controller.base.BaseController; | import com.iformall.controller.base.BaseController; | ||||
| import com.iformall.domain.po.WxBusinessCircleOrder; | |||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import com.iformall.enums.EnumThirdPartyConfigType; | |||||
| import com.iformall.interceptor.BodyReaderHttpServletRequestWrapper; | |||||
| import com.iformall.service.WxBusinessCircleOrderService; | |||||
| import com.iformall.service.WxMallService; | |||||
| import com.iformall.service.WxPayAccountService; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.web.bind.annotation.PostMapping; | |||||
| import org.springframework.web.bind.annotation.RequestMapping; | |||||
| import org.springframework.web.bind.annotation.ResponseBody; | |||||
| import org.springframework.web.bind.annotation.RestController; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import javax.servlet.http.HttpServletRequest; | import javax.servlet.http.HttpServletRequest; | ||||
| import java.text.ParseException; | |||||
| import java.text.SimpleDateFormat; | |||||
| import java.util.HashMap; | import java.util.HashMap; | ||||
| import java.util.Map; | import java.util.Map; | ||||
| @@ -18,23 +32,181 @@ public class WxBusinessOrderController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||||
| private final SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM-DDTHH:mm:ss+TIMEZONE"); | |||||
| @Autowired | |||||
| WxMallService wxMallService; | |||||
| @Autowired | |||||
| WxPayAccountService wxPayAccountService; | |||||
| @Autowired | |||||
| WxBusinessCircleOrderService wxBusinessCircleOrderService; | |||||
| /** | /** | ||||
| * | * | ||||
| * @return 微信商圈支付结果通知 | * @return 微信商圈支付结果通知 | ||||
| */ | */ | ||||
| @PostMapping(value = "/order") | |||||
| @PostMapping(value = "/order/{tenantId}") | |||||
| @ResponseBody | |||||
| public Map<String,String> createOrder(@PathVariable String tenantId, HttpServletRequest request){ | |||||
| logger.info("[" +getIpAddr() + "]微信商圈支付结果通知-----"+tenantId); | |||||
| Map<String,String> resultMap = new HashMap<>(); | |||||
| if(StringUtils.isBlank(tenantId)){ | |||||
| logger.error("微信商圈支付结果通知-----tenantId为空"); | |||||
| resultMap.put("code","FAIL"); | |||||
| return resultMap; | |||||
| } | |||||
| TenantEntity tenantEntity = wxMallService.getByTenantId(tenantId); | |||||
| if(tenantEntity == null){ | |||||
| logger.error("微信商圈支付结果通知-----获取tenantEntity为null"); | |||||
| resultMap.put("code","FAIL"); | |||||
| return resultMap; | |||||
| } | |||||
| WxPayService wxPayService = wxPayAccountService.getWxPayService(tenantId); | |||||
| if(wxPayService == null){ | |||||
| logger.error("微信商圈支付结果通知-----获取wxPayService失败"); | |||||
| resultMap.put("code","FAIL"); | |||||
| return resultMap; | |||||
| } | |||||
| try { | |||||
| //----------------签名验证----------- | |||||
| BusinessCircleNotifyData notifyData = verifySignature(request,wxPayService); | |||||
| logger.info("微信商圈支付结果通知---回调通知对象{}"+notifyData.toString()); | |||||
| //解密 | |||||
| PaidResult result = wxPayService.getBusinessCircleService().decryptPaidNotifyDataResource(notifyData); | |||||
| logger.info("微信商圈支付结果通知---解密结果{}"+notifyData.toString()); | |||||
| WxBusinessCircleOrder wxBusinessCircleOrder = new WxBusinessCircleOrder(); | |||||
| wxBusinessCircleOrder.updateTenantInfo(tenantEntity); | |||||
| wxBusinessCircleOrder.setSourceType(EnumThirdPartyConfigType.WEIXIN.getCode()); | |||||
| wxBusinessCircleOrder.setNoticeId(notifyData.getId()); | |||||
| wxBusinessCircleOrder.setNoticeCreateTime(sdf.parse(notifyData.getCreateTime())); | |||||
| wxBusinessCircleOrder.setNoticeEventType(notifyData.getEventType()); | |||||
| wxBusinessCircleOrder.setNoticeResourceType(notifyData.getResourceType()); | |||||
| wxBusinessCircleOrder.setSummary(notifyData.getSummary()); | |||||
| wxBusinessCircleOrder.setWxMchid(result.getMchid()); | |||||
| wxBusinessCircleOrder.setWxMerchantName(result.getMerchantName()); | |||||
| wxBusinessCircleOrder.setWxShopName(result.getShopName()); | |||||
| wxBusinessCircleOrder.setWxShopNumber(result.getShopNumber()); | |||||
| wxBusinessCircleOrder.setAppid(result.getAppid()); | |||||
| wxBusinessCircleOrder.setOpenid(result.getOpenid()); | |||||
| wxBusinessCircleOrder.setTimeEnd(sdf.parse(result.getTimeEnd())); | |||||
| wxBusinessCircleOrder.setAmount(result.getAmount()); | |||||
| wxBusinessCircleOrder.setTransactionId(result.getTransactionId()); | |||||
| wxBusinessCircleOrder.setCommitTag(result.getCommitTag()); | |||||
| wxBusinessCircleOrderService.createOrder(wxBusinessCircleOrder); | |||||
| resultMap.put("code","SUCCESS"); | |||||
| return resultMap; | |||||
| } catch (WxPayException e) { | |||||
| e.printStackTrace(); | |||||
| logger.error(e.getCustomErrorMsg()); | |||||
| resultMap.put("code","FAIL"); | |||||
| return resultMap; | |||||
| } catch (ParseException e) { | |||||
| e.printStackTrace(); | |||||
| logger.error("时间转换异常"); | |||||
| resultMap.put("code","FAIL"); | |||||
| return resultMap; | |||||
| } | |||||
| } | |||||
| /** | |||||
| * | |||||
| * @return 微信商圈退款成功通知 | |||||
| */ | |||||
| @PostMapping(value = "/refundOrder/{tenantId}") | |||||
| @ResponseBody | @ResponseBody | ||||
| public Map<String,String> createOrder(HttpServletRequest request){ | |||||
| logger.info("[" +getIpAddr() + "]微信商圈支付结果通知"); | |||||
| public Map<String,String> updateRefundOrder(@PathVariable String tenantId, HttpServletRequest request){ | |||||
| logger.info("[" +getIpAddr() + "]微信商圈退款成功通知-----"+tenantId); | |||||
| Map<String,String> resultMap = new HashMap<>(); | Map<String,String> resultMap = new HashMap<>(); | ||||
| if(StringUtils.isBlank(tenantId)){ | |||||
| logger.error("微信商圈退款成功通知-----tenantId为空"); | |||||
| resultMap.put("code","FAIL"); | |||||
| return resultMap; | |||||
| } | |||||
| TenantEntity tenantEntity = wxMallService.getByTenantId(tenantId); | |||||
| if(tenantEntity == null){ | |||||
| logger.error("微信商圈退款成功通知-----获取tenantEntity为null"); | |||||
| resultMap.put("code","FAIL"); | |||||
| return resultMap; | |||||
| } | |||||
| WxPayService wxPayService = wxPayAccountService.getWxPayService(tenantId); | |||||
| if(wxPayService == null){ | |||||
| logger.error("微信商圈退款成功通知-----获取wxPayService失败"); | |||||
| resultMap.put("code","FAIL"); | |||||
| return resultMap; | |||||
| } | |||||
| try { | |||||
| //----------------签名验证----------- | |||||
| BusinessCircleNotifyData notifyData = verifySignature(request,wxPayService); | |||||
| logger.info("微信商圈退款成功通知---回调通知对象{}"+notifyData.toString()); | |||||
| //解密 | |||||
| RefundResult result = wxPayService.getBusinessCircleService().decryptRefundNotifyDataResource(notifyData); | |||||
| logger.info("微信商圈退款成功通知---解密结果{}"+result.toString()); | |||||
| WxBusinessCircleOrder wxBusinessCircleOrder = new WxBusinessCircleOrder(); | |||||
| wxBusinessCircleOrder.updateTenantInfo(tenantEntity); | |||||
| wxBusinessCircleOrder.setSourceType(EnumThirdPartyConfigType.WEIXIN.getCode()); | |||||
| wxBusinessCircleOrder.setRefundNoticeId(notifyData.getId()); | |||||
| wxBusinessCircleOrder.setRefundCreateTime(sdf.parse(notifyData.getCreateTime())); | |||||
| wxBusinessCircleOrder.setRefundEventType(notifyData.getEventType()); | |||||
| wxBusinessCircleOrder.setRefundResourceType(notifyData.getResourceType()); | |||||
| wxBusinessCircleOrder.setRefundSummary(notifyData.getSummary()); | |||||
| wxBusinessCircleOrder.setTransactionId(result.getTransactionId()); | |||||
| wxBusinessCircleOrder.setWxMchid(result.getMchid()); | |||||
| wxBusinessCircleOrder.setWxMerchantName(result.getMerchantName()); | |||||
| wxBusinessCircleOrder.setWxShopName(result.getShopName()); | |||||
| wxBusinessCircleOrder.setWxShopNumber(result.getShopNumber()); | |||||
| wxBusinessCircleOrder.setAppid(result.getAppid()); | |||||
| wxBusinessCircleOrder.setOpenid(result.getOpenid()); | |||||
| wxBusinessCircleOrder.setRefundTime(sdf.parse(result.getRefundTime())); | |||||
| wxBusinessCircleOrder.setRefundAmount(result.getRefundAmount()); | |||||
| wxBusinessCircleOrder.setRefundId(result.getRefundId()); | |||||
| wxBusinessCircleOrderService.updateRefundOrder(wxBusinessCircleOrder); | |||||
| resultMap.put("code","SUCCESS"); | |||||
| return resultMap; | |||||
| } catch (WxPayException e) { | |||||
| e.printStackTrace(); | |||||
| logger.error(e.getCustomErrorMsg()); | |||||
| resultMap.put("code","FAIL"); | |||||
| return resultMap; | |||||
| } catch (ParseException e) { | |||||
| e.printStackTrace(); | |||||
| logger.error("时间转换异常"); | |||||
| resultMap.put("code","FAIL"); | |||||
| return resultMap; | |||||
| } | |||||
| resultMap.put("code","SUCCESS"); | |||||
| resultMap.put("code","SUCCESS"); | |||||
| return resultMap; | |||||
| } | } | ||||
| /** | |||||
| * 验签 | |||||
| */ | |||||
| private BusinessCircleNotifyData verifySignature(HttpServletRequest request,WxPayService wxPayService) throws WxPayException{ | |||||
| SignatureHeader header = new SignatureHeader(); | |||||
| header.setSerialNo(request.getHeader("Wechatpay-Serial")); | |||||
| header.setTimeStamp(request.getHeader("Wechatpay-Timestamp")); | |||||
| header.setNonce(request.getHeader("Wechatpay-Nonce")); | |||||
| header.setSigned(request.getHeader("Wechatpay-Signature")); | |||||
| String body = ((BodyReaderHttpServletRequestWrapper) request).getBody(); | |||||
| logger.info("微信商圈支付通知---body{}"+body); | |||||
| return wxPayService.getBusinessCircleService().parseNotifyData(body, header); | |||||
| } | |||||
| } | } | ||||
| @@ -1,26 +1,15 @@ | |||||
| package com.iformall.controller; | package com.iformall.controller; | ||||
| import com.alibaba.fastjson.JSON; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.WxCUserBasicInfo; | |||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import com.iformall.service.WxCUserBasicInfoService; | |||||
| import com.iformall.utils.HttpUtil; | |||||
| import com.iformall.utils.sign.SignUtils; | |||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| import io.swagger.annotations.ApiOperation; | import io.swagger.annotations.ApiOperation; | ||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.PostMapping; | import org.springframework.web.bind.annotation.PostMapping; | ||||
| import org.springframework.web.bind.annotation.RequestBody; | import org.springframework.web.bind.annotation.RequestBody; | ||||
| import org.springframework.web.bind.annotation.RequestMapping; | import org.springframework.web.bind.annotation.RequestMapping; | ||||
| import org.springframework.web.bind.annotation.RestController; | import org.springframework.web.bind.annotation.RestController; | ||||
| import java.util.Date; | |||||
| import java.util.HashMap; | |||||
| import java.util.Map; | import java.util.Map; | ||||
| @RestController | @RestController | ||||
| @@ -37,7 +26,7 @@ public class UserBusinessOrderController extends BaseController { | |||||
| * @return | * @return | ||||
| */ | */ | ||||
| @PostMapping("/order") | @PostMapping("/order") | ||||
| @ApiOperation(value = "商圈订单", notes = "") | |||||
| @ApiOperation(value = "订单", notes = "") | |||||
| public ResultData createOrder(@RequestBody Map<String,Object> map) { | public ResultData createOrder(@RequestBody Map<String,Object> map) { | ||||
| logger.info("UserBusinessOrderController >>>>>>>>>>>> createOrder >>>>>>>>>>>>>"+map.toString()); | logger.info("UserBusinessOrderController >>>>>>>>>>>> createOrder >>>>>>>>>>>>>"+map.toString()); | ||||
| @@ -96,6 +96,13 @@ public class BaseMyBatisConfiguration { | |||||
| wxCUserFromSharding.setCount(100); | wxCUserFromSharding.setCount(100); | ||||
| wxCUserFromSharding.setRule(EnumShardingRule.HASH.getCode()); | wxCUserFromSharding.setRule(EnumShardingRule.HASH.getCode()); | ||||
| shardingList.add(wxCUserFromSharding); | shardingList.add(wxCUserFromSharding); | ||||
| ShardingSphere wxBusinessCircleOrderSharding = new ShardingSphere(); | |||||
| wxBusinessCircleOrderSharding.setColumn("tenant_id"); | |||||
| wxBusinessCircleOrderSharding.setTableName("wx_business_circle_order"); | |||||
| wxBusinessCircleOrderSharding.setCount(100); | |||||
| wxBusinessCircleOrderSharding.setRule(EnumShardingRule.HASH.getCode()); | |||||
| shardingList.add(wxBusinessCircleOrderSharding); | |||||
| ShardingSphere wxOrderSharding = new ShardingSphere(); | ShardingSphere wxOrderSharding = new ShardingSphere(); | ||||
| wxOrderSharding.setColumn("tenant_id"); | wxOrderSharding.setColumn("tenant_id"); | ||||
| @@ -0,0 +1,153 @@ | |||||
| package com.iformall.domain.po; | |||||
| import com.baomidou.mybatisplus.annotation.TableField; | |||||
| import com.baomidou.mybatisplus.annotation.TableName; | |||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import lombok.Data; | |||||
| import lombok.EqualsAndHashCode; | |||||
| import lombok.ToString; | |||||
| import java.math.BigDecimal; | |||||
| import java.util.Date; | |||||
| @TableName(value = "wx_business_circle_order") | |||||
| @Data | |||||
| @ToString(callSuper = true) | |||||
| @EqualsAndHashCode(callSuper = true) | |||||
| public class WxBusinessCircleOrder extends TenantEntity { | |||||
| protected Long id; | |||||
| @io.swagger.annotations.ApiModelProperty(value="来源类型(1:来自微信)",name="sourceType") | |||||
| private Integer sourceType; | |||||
| @io.swagger.annotations.ApiModelProperty(value="商圈支付结果通知Id",name="noticeId") | |||||
| private String noticeId; | |||||
| @io.swagger.annotations.ApiModelProperty(value="商圈支付结果通知创建时间",name="noticeCreateTime") | |||||
| private Date noticeCreateTime; | |||||
| @io.swagger.annotations.ApiModelProperty(value="商圈支付结果通知类型:MALL_TRANSACTION.SUCCESS",name="noticeEventType") | |||||
| private String noticeEventType; | |||||
| @io.swagger.annotations.ApiModelProperty(value="商圈支付结果通知资源数据类型:encrypt-resource",name="noticeResourceType") | |||||
| private String noticeResourceType; | |||||
| @io.swagger.annotations.ApiModelProperty(value="商圈支付结果通知回调摘要",name="summary") | |||||
| private String summary; | |||||
| @io.swagger.annotations.ApiModelProperty(value="微信支付分配的商户号",name="wxMchid") | |||||
| private String wxMchid; | |||||
| @io.swagger.annotations.ApiModelProperty(value="商圈商户名称",name="wxMerchantName") | |||||
| private String wxMerchantName; | |||||
| @io.swagger.annotations.ApiModelProperty(value="门店名称,商圈在商圈小程序上圈店时填写的门店名称",name="wxShopName") | |||||
| private String wxShopName; | |||||
| @io.swagger.annotations.ApiModelProperty(value="门店编号,商圈在商圈小程序上圈店时填写的门店编号,用于跟商圈自身已有的商户识别码对齐",name="wxShopNumber") | |||||
| private String wxShopNumber; | |||||
| @io.swagger.annotations.ApiModelProperty(value="小程序appid",name="appid") | |||||
| private String appid; | |||||
| @io.swagger.annotations.ApiModelProperty(value="openid",name="openid") | |||||
| private String openid; | |||||
| @io.swagger.annotations.ApiModelProperty(value="交易完成时间",name="timeEnd") | |||||
| private Date timeEnd; | |||||
| @io.swagger.annotations.ApiModelProperty(value="用户实际消费金额,单位(分)",name="amount") | |||||
| private Integer amount; | |||||
| @TableField(exist = false) | |||||
| @io.swagger.annotations.ApiModelProperty(value="用户实际消费金额,单位(元)",name="amount") | |||||
| private String amountStr; | |||||
| public String getAmountStr() { | |||||
| return amount != null ? new BigDecimal(amount).divide(new BigDecimal(100)).toPlainString(): amountStr; | |||||
| } | |||||
| @io.swagger.annotations.ApiModelProperty(value="支付订单号",name="transactionId") | |||||
| private String transactionId; | |||||
| @io.swagger.annotations.ApiModelProperty(value="手动提交积分标记,自动提交时无该字段,用于区分用户手动申请后推送的积分",name="commitTag") | |||||
| private String commitTag; | |||||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createTime") | |||||
| private Date createTime; | |||||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateTime") | |||||
| private Date updateTime; | |||||
| @io.swagger.annotations.ApiModelProperty(value="门店Id,与wx_shop_number对齐",name="merchantId") | |||||
| private Long merchantId; | |||||
| @io.swagger.annotations.ApiModelProperty(value="c端会员id,与openid对齐",name="cUserId") | |||||
| private Long cUserId; | |||||
| @io.swagger.annotations.ApiModelProperty(value="是否获得积分(1:是,0:否)",name="earnPoints") | |||||
| private Integer earnPoints; | |||||
| @io.swagger.annotations.ApiModelProperty(value="订单新增积分值",name="increasedPoints") | |||||
| private Integer increasedPoints; | |||||
| @io.swagger.annotations.ApiModelProperty(value="积分更新时间(新增)",name="increasedPoints") | |||||
| private Date pointsUpdateTime; | |||||
| @io.swagger.annotations.ApiModelProperty(value="是否积分同步(1:是,0:否)",name="isPointsNotify") | |||||
| private Integer isPointsNotify; | |||||
| @io.swagger.annotations.ApiModelProperty(value="是否退款(1:是,0:否)",name="isRefund") | |||||
| private Integer isRefund; | |||||
| @io.swagger.annotations.ApiModelProperty(value="退款通知唯一ID",name="refundNoticeId") | |||||
| private String refundNoticeId; | |||||
| @io.swagger.annotations.ApiModelProperty(value="退款通知创建时间",name="refundCreateTime") | |||||
| private Date refundCreateTime; | |||||
| @io.swagger.annotations.ApiModelProperty(value="退款通知的类型为:MALL_REFUND.SUCCESS",name="refundEventType") | |||||
| private String refundEventType; | |||||
| @io.swagger.annotations.ApiModelProperty(value="退款通知的资源数据类型",name="refundResourceType") | |||||
| private String refundResourceType; | |||||
| @io.swagger.annotations.ApiModelProperty(value="退款回调摘要",name="refundSummary") | |||||
| private String refundSummary; | |||||
| @io.swagger.annotations.ApiModelProperty(value="退款完成时间",name="refundTime") | |||||
| private Date refundTime; | |||||
| @io.swagger.annotations.ApiModelProperty(value="用户退款金额,单位(分)",name="refundSummary") | |||||
| private Integer refundAmount; | |||||
| @TableField(exist = false) | |||||
| @io.swagger.annotations.ApiModelProperty(value="用户退款金额,单位(元)",name="amount") | |||||
| private String refundAmountStr; | |||||
| public String getRefundAmountStr() { | |||||
| return refundAmount != null ? new BigDecimal(refundAmount).divide(new BigDecimal(100)).toPlainString(): refundAmountStr; | |||||
| } | |||||
| @io.swagger.annotations.ApiModelProperty(value="微信支付退款单号",name="refundId") | |||||
| private String refundId; | |||||
| @io.swagger.annotations.ApiModelProperty(value="用户是否退积分(1:是,0:否)",name="isRefundPoints") | |||||
| private Integer isRefundPoints; | |||||
| @io.swagger.annotations.ApiModelProperty(value="用户退积分时间",name="refundPointsTime") | |||||
| private Date refundPointsTime; | |||||
| @TableField(exist = false) | |||||
| @io.swagger.annotations.ApiModelProperty(value="查询-开始时间",name="startdate") | |||||
| private Date startTime; | |||||
| @TableField(exist = false) | |||||
| @io.swagger.annotations.ApiModelProperty(value="查询-结束时间",name="enddate") | |||||
| private Date endTime; | |||||
| } | |||||
| @@ -16,6 +16,8 @@ public class WxPayAccount extends TenantEntity { | |||||
| private String mchId; | private String mchId; | ||||
| @io.swagger.annotations.ApiModelProperty(value="微信服务商号",name="subMchId") | @io.swagger.annotations.ApiModelProperty(value="微信服务商号",name="subMchId") | ||||
| private String subMchId; | private String subMchId; | ||||
| @io.swagger.annotations.ApiModelProperty(value="服务商模式下的子商户公众账号ID",name="subAppId") | |||||
| private String subAppId; | |||||
| @io.swagger.annotations.ApiModelProperty(value="支付密钥",name="apiKey") | @io.swagger.annotations.ApiModelProperty(value="支付密钥",name="apiKey") | ||||
| private String apiKey; | private String apiKey; | ||||
| @io.swagger.annotations.ApiModelProperty(value="微信回调,支持3种回调,(1.url/pay 2.url/refund3.url/separate)",name="notifyUrl") | @io.swagger.annotations.ApiModelProperty(value="微信回调,支持3种回调,(1.url/pay 2.url/refund3.url/separate)",name="notifyUrl") | ||||
| @@ -31,6 +33,7 @@ public class WxPayAccount extends TenantEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value="实际手续费(万分之几,默认60)",name="realRate") | @io.swagger.annotations.ApiModelProperty(value="实际手续费(万分之几,默认60)",name="realRate") | ||||
| private Integer realRate; | private Integer realRate; | ||||
| public String getPayNotifyUrl() { | public String getPayNotifyUrl() { | ||||
| return notifyUrl + "/pay"; | return notifyUrl + "/pay"; | ||||
| } | } | ||||
| @@ -43,4 +46,17 @@ public class WxPayAccount extends TenantEntity { | |||||
| public boolean checkShare() { return share > 0; } | public boolean checkShare() { return share > 0; } | ||||
| @io.swagger.annotations.ApiModelProperty(value="微信支付分serviceId",name="serviceId") | |||||
| private String serviceId; | |||||
| @io.swagger.annotations.ApiModelProperty(value="微信支付分回调地址",name="payScoreNotifyUrl") | |||||
| private String payScoreNotifyUrl; | |||||
| @io.swagger.annotations.ApiModelProperty(value="apiV3秘钥",name="apiV3Key") | |||||
| private String apiV3Key; | |||||
| @io.swagger.annotations.ApiModelProperty(value="证书序列号",name="certSerialNo") | |||||
| private String certSerialNo; | |||||
| @io.swagger.annotations.ApiModelProperty(value="apiv3 商户apiclient_key.pem 商户私钥",name="privateKeyPath") | |||||
| private String privateKeyPath; | |||||
| @io.swagger.annotations.ApiModelProperty(value="apiv3 商户apiclient_cert.pem",name="privateCertPath") | |||||
| private String privateCertPath; | |||||
| } | } | ||||
| @@ -6,6 +6,7 @@ package com.iformall.enums; | |||||
| */ | */ | ||||
| public enum EnumThirdPartyConfigType { | public enum EnumThirdPartyConfigType { | ||||
| WEIXIN(1, "微信"), | |||||
| GOOAGOO(5, "数衍科技"), | GOOAGOO(5, "数衍科技"), | ||||
| ; | ; | ||||
| @@ -0,0 +1,42 @@ | |||||
| package com.iformall.mapper; | |||||
| import com.iformall.common.CommonMapper; | |||||
| import com.iformall.domain.po.WxBusinessCircleOrder; | |||||
| import java.util.List; | |||||
| public interface WxBusinessCircleOrderMapper extends CommonMapper<WxBusinessCircleOrder, Long> { | |||||
| List<WxBusinessCircleOrder> findList(WxBusinessCircleOrder record); | |||||
| WxBusinessCircleOrder getByTransactionId(WxBusinessCircleOrder wxBusinessCircleOrder); | |||||
| /** | |||||
| * 成功通知新建 | |||||
| * @param wxBusinessCircleOrder | |||||
| */ | |||||
| void insertNoticeOrder(WxBusinessCircleOrder wxBusinessCircleOrder); | |||||
| /** | |||||
| * 加积分 | |||||
| * @param wxBusinessCircleOrder | |||||
| */ | |||||
| void updateAddPoints(WxBusinessCircleOrder wxBusinessCircleOrder); | |||||
| /** | |||||
| * 积分同步状态修改 | |||||
| */ | |||||
| void updateIsPointsNotify(WxBusinessCircleOrder wxBusinessCircleOrder); | |||||
| /** | |||||
| * 退款 | |||||
| * @param wxBusinessCircleOrder | |||||
| */ | |||||
| void updateRefundNoticeOrder(WxBusinessCircleOrder wxBusinessCircleOrder); | |||||
| /** | |||||
| * 退积分 | |||||
| * @param wxBusinessCircleOrder | |||||
| */ | |||||
| void updateRefundPoints(WxBusinessCircleOrder wxBusinessCircleOrder); | |||||
| } | |||||
| @@ -0,0 +1,23 @@ | |||||
| package com.iformall.service; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.po.WxBusinessCircleOrder; | |||||
| public interface WxBusinessCircleOrderService { | |||||
| /** | |||||
| * 根据实体查询分页列表 | |||||
| * | |||||
| * @param record | |||||
| * @param pageIndex | |||||
| * @param pageSize | |||||
| * @return | |||||
| */ | |||||
| PageInfo<WxBusinessCircleOrder> listAsPage(WxBusinessCircleOrder record, Integer pageIndex, Integer pageSize); | |||||
| void createOrder(WxBusinessCircleOrder wxBusinessCircleOrder); | |||||
| void updateRefundOrder(WxBusinessCircleOrder wxBusinessCircleOrder); | |||||
| } | |||||
| @@ -1,5 +1,6 @@ | |||||
| package com.iformall.service; | package com.iformall.service; | ||||
| import com.github.binarywang.wxpay.service.WxPayService; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.domain.po.WxPayAccount; | import com.iformall.domain.po.WxPayAccount; | ||||
| import com.iformall.domain.po.WxProjectConfig; | import com.iformall.domain.po.WxProjectConfig; | ||||
| @@ -50,4 +51,6 @@ public interface WxPayAccountService { | |||||
| WxPayAccount getByTenantId(String te); | WxPayAccount getByTenantId(String te); | ||||
| WxPayService getWxPayService(String tenantId); | |||||
| } | } | ||||
| @@ -0,0 +1,89 @@ | |||||
| package com.iformall.service.impl; | |||||
| import com.github.pagehelper.PageHelper; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.common.IdWorker; | |||||
| import com.iformall.domain.po.WxBusinessCircleOrder; | |||||
| import com.iformall.domain.po.WxCUser; | |||||
| import com.iformall.domain.po.WxMerchant; | |||||
| import com.iformall.mapper.WxBusinessCircleOrderMapper; | |||||
| import com.iformall.service.WxBusinessCircleOrderService; | |||||
| import com.iformall.service.WxCUserService; | |||||
| import com.iformall.service.WxMerchantService; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | |||||
| import java.util.Date; | |||||
| @Service | |||||
| public class WxBusinessCircleOrderServiceImpl implements WxBusinessCircleOrderService { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| WxBusinessCircleOrderMapper wxBusinessCircleOrderMapper; | |||||
| @Autowired | |||||
| WxMerchantService wxMerchantService; | |||||
| @Autowired | |||||
| WxCUserService wxCUserService; | |||||
| @Override | |||||
| public PageInfo<WxBusinessCircleOrder> listAsPage(WxBusinessCircleOrder record, Integer pageIndex, Integer pageSize) { | |||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxBusinessCircleOrderMapper.findList(record)); | |||||
| } | |||||
| @Override | |||||
| public void createOrder(WxBusinessCircleOrder wxBusinessCircleOrder) { | |||||
| WxBusinessCircleOrder byTransactionId = wxBusinessCircleOrderMapper.getByTransactionId(wxBusinessCircleOrder); | |||||
| if(byTransactionId != null){ | |||||
| logger.error("--商圈付款--通知消息已存在--"); | |||||
| }else{ | |||||
| Date now = new Date(); | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| wxBusinessCircleOrder.setId(idWorker.nextId()); | |||||
| wxBusinessCircleOrder.setCreateTime(now); | |||||
| wxBusinessCircleOrder.setUpdateTime(now); | |||||
| WxMerchant wxMerchant = wxMerchantService.getById(Long.parseLong(wxBusinessCircleOrder.getWxShopNumber())); | |||||
| if(wxMerchant != null){ | |||||
| wxBusinessCircleOrder.setMerchantId(wxMerchant.getId()); | |||||
| }else{ | |||||
| logger.error("--商圈付款通知消息未找到门店--"); | |||||
| } | |||||
| WxCUser userQ = new WxCUser(); | |||||
| userQ.updateTenantInfo(wxBusinessCircleOrder); | |||||
| userQ.setOpenId(wxBusinessCircleOrder.getOpenid()); | |||||
| userQ.setAppId(wxBusinessCircleOrder.getAppid()); | |||||
| WxCUser user = wxCUserService.getByOpenId(userQ); | |||||
| if(user != null && user.getUserId() != null){ | |||||
| wxBusinessCircleOrder.setCUserId(user.getUserId()); | |||||
| }else{ | |||||
| logger.error("--商圈付款通知消息未找到会员--"); | |||||
| } | |||||
| wxBusinessCircleOrderMapper.insertNoticeOrder(wxBusinessCircleOrder); | |||||
| // TODO: 2021/4/21 mq 新增积分 积分同步 | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void updateRefundOrder(WxBusinessCircleOrder wxBusinessCircleOrder) { | |||||
| WxBusinessCircleOrder byTransactionId = wxBusinessCircleOrderMapper.getByTransactionId(wxBusinessCircleOrder); | |||||
| if(byTransactionId == null){ | |||||
| logger.error("--商圈退款--付款消息未找到--"); | |||||
| }else{ | |||||
| Date now = new Date(); | |||||
| wxBusinessCircleOrder.setId(byTransactionId.getId()); | |||||
| wxBusinessCircleOrder.setUpdateTime(now); | |||||
| wxBusinessCircleOrderMapper.updateRefundNoticeOrder(wxBusinessCircleOrder); | |||||
| // TODO: 2021/4/21 mq 退积分 | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -653,6 +653,7 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService,IExc | |||||
| this.save(basicInfo); | this.save(basicInfo); | ||||
| return basicInfo; | return basicInfo; | ||||
| } | } | ||||
| // TODO: 2021/4/21 重新组装数据结构 | |||||
| } | } | ||||
| @@ -1,11 +1,17 @@ | |||||
| package com.iformall.service.impl; | package com.iformall.service.impl; | ||||
| import com.github.binarywang.wxpay.service.WxPayService; | |||||
| import com.github.pagehelper.PageHelper; | import com.github.pagehelper.PageHelper; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.domain.po.WxAppinfo; | |||||
| import com.iformall.domain.po.WxPayAccount; | import com.iformall.domain.po.WxPayAccount; | ||||
| import com.iformall.domain.po.WxProjectConfig; | import com.iformall.domain.po.WxProjectConfig; | ||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import com.iformall.enums.EnumPayWay; | |||||
| import com.iformall.mapper.WxPayAccountMapper; | import com.iformall.mapper.WxPayAccountMapper; | ||||
| import com.iformall.service.WxAppinfoService; | |||||
| import com.iformall.service.WxPayAccountService; | import com.iformall.service.WxPayAccountService; | ||||
| import com.iformall.utils.MaUtil; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| @@ -19,6 +25,9 @@ public class WxPayAccountServiceImpl implements WxPayAccountService { | |||||
| @Autowired | @Autowired | ||||
| WxPayAccountMapper wxPayAccountMapper; | WxPayAccountMapper wxPayAccountMapper; | ||||
| @Autowired | |||||
| WxAppinfoService wxAppinfoService; | |||||
| @Override | @Override | ||||
| public WxPayAccount wxPayAccountInit(String tenantId, WxProjectConfig wxProjectConfig) { | public WxPayAccount wxPayAccountInit(String tenantId, WxProjectConfig wxProjectConfig) { | ||||
| @@ -71,5 +80,19 @@ public class WxPayAccountServiceImpl implements WxPayAccountService { | |||||
| return wxPayAccountMapper.getByTenantId(tenantId); | return wxPayAccountMapper.getByTenantId(tenantId); | ||||
| } | } | ||||
| @Override | |||||
| public WxPayService getWxPayService(String tenantId) { | |||||
| TenantEntity tenantEntity = new TenantEntity(); | |||||
| tenantEntity.setTenantId(tenantId); | |||||
| WxAppinfo cAppInfo = wxAppinfoService.getCAppInfo(tenantEntity, EnumPayWay.PAY_WAY_WECHAT); | |||||
| WxPayAccount payAccount = this.getByTenantId(tenantId); | |||||
| if(cAppInfo != null && payAccount != null){ | |||||
| return MaUtil.getWxPayService(cAppInfo,payAccount); | |||||
| }else{ | |||||
| return null; | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -3,8 +3,12 @@ package com.iformall.utils; | |||||
| import cn.binarywang.wx.miniapp.api.WxMaService; | import cn.binarywang.wx.miniapp.api.WxMaService; | ||||
| import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl; | import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl; | ||||
| import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl; | import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl; | ||||
| import com.github.binarywang.wxpay.config.WxPayConfig; | |||||
| import com.github.binarywang.wxpay.service.WxPayService; | |||||
| import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl; | |||||
| import com.iformall.common.FmHttpClientBuilder; | import com.iformall.common.FmHttpClientBuilder; | ||||
| import com.iformall.domain.po.WxAppinfo; | import com.iformall.domain.po.WxAppinfo; | ||||
| import com.iformall.domain.po.WxPayAccount; | |||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| public class MaUtil { | public class MaUtil { | ||||
| @@ -25,4 +29,27 @@ public class MaUtil { | |||||
| service.setWxMaConfig(config); | service.setWxMaConfig(config); | ||||
| return service; | return service; | ||||
| } | } | ||||
| static public WxPayService getWxPayService(WxAppinfo appinfo, WxPayAccount payAccount) { | |||||
| WxPayConfig config = new WxPayConfig(); | |||||
| config.setAppId(appinfo.getAppId()); | |||||
| config.setMchId(payAccount.getMchId()); | |||||
| config.setMchKey(payAccount.getApiKey()); | |||||
| config.setSubAppId(appinfo.getAppId()); | |||||
| config.setSubMchId(payAccount.getSubMchId()); | |||||
| config.setKeyPath(payAccount.getCertPath()); | |||||
| //以下是apiv3以及支付分相关 | |||||
| // config.setServiceId(); | |||||
| // config.setPayScoreNotifyUrl(); | |||||
| // TODO: 2021/4/20 | |||||
| config.setPrivateKeyPath(null);//apiv3 商户apiclient_key.pem 商户私钥 | |||||
| config.setPrivateCertPath(null);//apiv3 商户apiclient_cert.pem | |||||
| config.setCertSerialNo(null);//证书序列号 | |||||
| config.setApiV3Key(null);//apiV3秘钥 | |||||
| WxPayService wxPayService = new WxPayServiceImpl(); | |||||
| wxPayService.setConfig(config); | |||||
| return wxPayService; | |||||
| } | |||||
| } | } | ||||
| @@ -0,0 +1,219 @@ | |||||
| <?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.iformall.mapper.WxBusinessCircleOrderMapper"> | |||||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxBusinessCircleOrder"> | |||||
| <id column="id" jdbcType="BIGINT" property="id"/> | |||||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> | |||||
| <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" /> | |||||
| <result column="source_type" jdbcType="TINYINT" property="sourceType"/> | |||||
| <result column="notice_id" jdbcType="VARCHAR" property="noticeId" /> | |||||
| <result column="notice_create_time" jdbcType="TIMESTAMP" property="noticeCreateTime"/> | |||||
| <result column="notice_event_type" jdbcType="VARCHAR" property="noticeEventType" /> | |||||
| <result column="notice_resource_type" jdbcType="VARCHAR" property="noticeResourceType" /> | |||||
| <result column="summary" jdbcType="VARCHAR" property="summary" /> | |||||
| <result column="wx_mchid" jdbcType="VARCHAR" property="wxMchid" /> | |||||
| <result column="wx_merchant_name" jdbcType="VARCHAR" property="wxMerchantName" /> | |||||
| <result column="wx_shop_name" jdbcType="VARCHAR" property="wxShopName" /> | |||||
| <result column="wx_shop_number" jdbcType="VARCHAR" property="wxShopNumber" /> | |||||
| <result column="appid" jdbcType="VARCHAR" property="appid" /> | |||||
| <result column="openid" jdbcType="VARCHAR" property="openid" /> | |||||
| <result column="time_end" jdbcType="TIMESTAMP" property="timeEnd"/> | |||||
| <result column="amount" jdbcType="INTEGER" property="amount"/> | |||||
| <result column="transaction_id" jdbcType="VARCHAR" property="transactionId" /> | |||||
| <result column="commit_tag" jdbcType="VARCHAR" property="commitTag" /> | |||||
| <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/> | |||||
| <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/> | |||||
| <result column="merchant_id" jdbcType="BIGINT" property="merchantId"/> | |||||
| <result column="c_user_id" jdbcType="BIGINT" property="cUserId"/> | |||||
| <result column="earn_points" jdbcType="TINYINT" property="earnPoints"/> | |||||
| <result column="increased_points" jdbcType="INTEGER" property="increasedPoints"/> | |||||
| <result column="points_update_time" jdbcType="TIMESTAMP" property="pointsUpdateTime"/> | |||||
| <result column="is_points_notify" jdbcType="TINYINT" property="isPointsNotify"/> | |||||
| <result column="is_refund" jdbcType="TINYINT" property="isRefund"/> | |||||
| <result column="refund_notice_id" jdbcType="VARCHAR" property="refundNoticeId" /> | |||||
| <result column="refund_create_time" jdbcType="TIMESTAMP" property="refundCreateTime"/> | |||||
| <result column="refund_event_type" jdbcType="VARCHAR" property="refundEventType" /> | |||||
| <result column="refund_resource_type" jdbcType="VARCHAR" property="refundResourceType" /> | |||||
| <result column="refund_summary" jdbcType="VARCHAR" property="refundSummary" /> | |||||
| <result column="refund_time" jdbcType="TIMESTAMP" property="refundTime"/> | |||||
| <result column="refund_amount" jdbcType="INTEGER" property="refundAmount"/> | |||||
| <result column="refund_id" jdbcType="VARCHAR" property="refundId" /> | |||||
| <result column="is_refund_points" jdbcType="TINYINT" property="isRefundPoints"/> | |||||
| <result column="refund_points_time" jdbcType="TIMESTAMP" property="refundPointsTime"/> | |||||
| </resultMap> | |||||
| <sql id="allColumns"> | |||||
| `id`, `tenant_id`, `parent_tenant_id`, `source_type`, `notice_id`, `notice_create_time`, `notice_event_type`, | |||||
| `notice_resource_type`, `summary`, `wx_mchid`, `wx_merchant_name`, `wx_shop_name`, `wx_shop_number`, | |||||
| `appid`, `openid`, `time_end`, `amount`, `transaction_id`, `commit_tag`, `create_time`, `update_time`, | |||||
| `merchant_id`, `c_user_id`, `earn_points`, `increased_points`, `points_update_time`, `is_points_notify`, | |||||
| `is_refund`, `refund_notice_id`, `refund_create_time`, `refund_event_type`, `refund_resource_type`, | |||||
| `refund_summary`, `refund_time`, `refund_amount`, `refund_id`, `is_refund_points`, `refund_points_time` | |||||
| </sql> | |||||
| <sql id="dynamicWhereConditions"> | |||||
| where 1 = 1 | |||||
| <if test=" null != id "> | |||||
| and `id` = #{id} | |||||
| </if> | |||||
| <if test=" null != tenantId and '' != tenantId"> | |||||
| and `tenant_id` = #{tenantId} | |||||
| </if> | |||||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||||
| and `parent_tenant_id` = #{parentTenantId} | |||||
| </if> | |||||
| <if test=" null != sourceType "> | |||||
| and `source_type` = #{sourceType} | |||||
| </if> | |||||
| <if test=" null != noticeId and '' != noticeId"> | |||||
| and `notice_id` = #{noticeId} | |||||
| </if> | |||||
| <if test=" null != wxMchid and '' != wxMchid"> | |||||
| and `wx_mchid` = #{wxMchid} | |||||
| </if> | |||||
| <if test=" null != wxMerchantName "> | |||||
| and `wx_merchant_name` like concat('%', #{wxMerchantName},'%') | |||||
| </if> | |||||
| <if test=" null != wxShopName "> | |||||
| and `wx_shop_name` like concat('%', #{wxShopName},'%') | |||||
| </if> | |||||
| <if test=" null != wxShopNumber and '' != wxShopNumber"> | |||||
| and `wx_shop_number` = #{wxShopNumber} | |||||
| </if> | |||||
| <if test=" null != appid and '' != appid"> | |||||
| and `appid` = #{appid} | |||||
| </if> | |||||
| <if test=" null != openid and '' != openid"> | |||||
| and `openid` = #{openid} | |||||
| </if> | |||||
| <if test=" null != startTime "> | |||||
| and `time_end` >= #{startTime} | |||||
| </if> | |||||
| <if test=" null != endTime"> | |||||
| and `time_end` < #{endTime} | |||||
| </if> | |||||
| <if test=" null != transactionId and '' != transactionId"> | |||||
| and `transaction_id` = #{transactionId} | |||||
| </if> | |||||
| <if test=" null != merchantId "> | |||||
| and `merchant_id` = #{merchantId} | |||||
| </if> | |||||
| <if test=" null != cUserId "> | |||||
| and `c_user_id` = #{cUserId} | |||||
| </if> | |||||
| <if test=" null != earnPoints "> | |||||
| and `earn_points` = #{earnPoints} | |||||
| </if> | |||||
| <if test=" null != isPointsNotify "> | |||||
| and `is_points_notify` = #{isPointsNotify} | |||||
| </if> | |||||
| <if test=" null != isRefund "> | |||||
| and `is_refund` = #{isRefund} | |||||
| </if> | |||||
| <if test=" null != refundNoticeId and '' != refundNoticeId"> | |||||
| and `refund_notice_id` = #{refundNoticeId} | |||||
| </if> | |||||
| <if test=" null != refundId and '' != refundId"> | |||||
| and `refund_id` = #{refundId} | |||||
| </if> | |||||
| <if test=" null != isRefundPoints"> | |||||
| and `is_refund_points` = #{isRefundPoints} | |||||
| </if> | |||||
| <if test=" null != ids "> | |||||
| and `id` in | |||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||||
| #{idItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != sortColumns">order by ${sortColumns}</if> | |||||
| </sql> | |||||
| <select id="findList" parameterType="com.iformall.domain.po.WxBusinessCircleOrder" resultMap="BaseResultMap"> | |||||
| select | |||||
| <include refid="allColumns"/> | |||||
| from wx_business_circle_order | |||||
| <include refid="dynamicWhereConditions"/> | |||||
| </select> | |||||
| <select id="getByTransactionId" parameterType="com.iformall.domain.po.WxBusinessCircleOrder" resultMap="BaseResultMap"> | |||||
| select | |||||
| <include refid="allColumns"/> | |||||
| from wx_business_circle_order | |||||
| where `transaction_id` = #{transactionId} | |||||
| and tenant_id=#{tenantId} | |||||
| </select> | |||||
| <insert id="insertNoticeOrder" parameterType="com.iformall.domain.po.WxBusinessCircleOrder" > | |||||
| INSERT INTO wx_business_circle_order ( | |||||
| `id`, `tenant_id`, `parent_tenant_id`, `source_type`, `notice_id`, `notice_create_time`, `notice_event_type`, | |||||
| `notice_resource_type`, `summary`, `wx_mchid`, `wx_merchant_name`, `wx_shop_name`, `wx_shop_number`, | |||||
| `appid`, `openid`, `time_end`, `amount`, `transaction_id`, `commit_tag`, `create_time`, `update_time`, | |||||
| `merchant_id`, `c_user_id`, `earn_points`, `is_points_notify`, `is_refund` | |||||
| ) | |||||
| VALUES( | |||||
| #{id},#{tenantId},#{parentTenantId},#{sourceType},#{noticeId},#{noticeCreateTime},#{noticeEventType}, | |||||
| #{noticeResourceType},#{summary},#{wxMchid},#{wxMerchantName},#{wxShopName},#{wxShopNumber}, | |||||
| #{appid},#{openid},#{timeEnd},#{amount},#{transactionId},#{commitTag},#{createTime},#{updateTime}, | |||||
| #{merchantId},#{cUserId},0,0,0 | |||||
| ); | |||||
| </insert> | |||||
| <update id="updateAddPoints" parameterType="com.iformall.domain.po.WxBusinessCircleOrder"> | |||||
| update wx_business_circle_order set | |||||
| `earn_points` = 1, `increased_points` = #{increasedPoints}, `points_update_time` = #{pointsUpdateTime}, | |||||
| `is_refund_points` = 0, #{updateTime} | |||||
| where `id` = #{id} and `tenant_id` = #{tenantId} | |||||
| </update> | |||||
| <update id="updateIsPointsNotify" parameterType="com.iformall.domain.po.WxBusinessCircleOrder"> | |||||
| update wx_business_circle_order set | |||||
| `is_points_notify` = 1, #{updateTime} | |||||
| where `id` = #{id} and `tenant_id` = #{tenantId} | |||||
| </update> | |||||
| <update id="updateRefundNoticeOrder" parameterType="com.iformall.domain.po.WxBusinessCircleOrder"> | |||||
| update wx_business_circle_order set | |||||
| `is_refund` = 1, `refund_notice_id` = #{refundNoticeId}, `refund_create_time` = #{refundCreateTime}, | |||||
| `refund_event_type` = #{refundEventType}, `refund_resource_type` = #{refundResourceType}, `refund_summary` = #{refundSummary}, | |||||
| `refund_time` = #{refundTime}, `refund_amount` = #{refundAmount}, `refund_id` = #{refundId}, #{updateTime} | |||||
| where `id` = #{id} and `tenant_id` = #{tenantId} | |||||
| </update> | |||||
| <update id="updateRefundPoints" parameterType="com.iformall.domain.po.WxBusinessCircleOrder"> | |||||
| update wx_business_circle_order set | |||||
| `is_refund_points` = 1, `refund_points_time` = #{refundPointsTime}, #{updateTime} | |||||
| where `id` = #{id} and `tenant_id` = #{tenantId} | |||||
| </update> | |||||
| </mapper> | |||||
| @@ -7,6 +7,7 @@ | |||||
| <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" /> | <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" /> | ||||
| <result column="mch_id" jdbcType="VARCHAR" property="mchId"/> | <result column="mch_id" jdbcType="VARCHAR" property="mchId"/> | ||||
| <result column="sub_mch_id" jdbcType="VARCHAR" property="subMchId"/> | <result column="sub_mch_id" jdbcType="VARCHAR" property="subMchId"/> | ||||
| <result column="sub_app_id" jdbcType="VARCHAR" property="subAppId"/> | |||||
| <result column="api_key" jdbcType="VARCHAR" property="apiKey"/> | <result column="api_key" jdbcType="VARCHAR" property="apiKey"/> | ||||
| <result column="notify_url" jdbcType="VARCHAR" property="notifyUrl"/> | <result column="notify_url" jdbcType="VARCHAR" property="notifyUrl"/> | ||||
| <result column="cert_path" jdbcType="VARCHAR" property="certPath"/> | <result column="cert_path" jdbcType="VARCHAR" property="certPath"/> | ||||
| @@ -14,10 +15,19 @@ | |||||
| <result column="share" jdbcType="INTEGER" property="share"/> | <result column="share" jdbcType="INTEGER" property="share"/> | ||||
| <result column="rate" jdbcType="INTEGER" property="rate"/> | <result column="rate" jdbcType="INTEGER" property="rate"/> | ||||
| <result column="real_rate" jdbcType="INTEGER" property="realRate"/> | <result column="real_rate" jdbcType="INTEGER" property="realRate"/> | ||||
| <result column="service_id" jdbcType="VARCHAR" property="serviceId"/> | |||||
| <result column="pay_score_notify_url" jdbcType="VARCHAR" property="payScoreNotifyUrl"/> | |||||
| <result column="api_v3_key" jdbcType="VARCHAR" property="apiV3Key"/> | |||||
| <result column="cert_serial_no" jdbcType="VARCHAR" property="certSerialNo"/> | |||||
| <result column="private_key_path" jdbcType="VARCHAR" property="privateKeyPath"/> | |||||
| <result column="private_cert_path" jdbcType="VARCHAR" property="privateCertPath"/> | |||||
| </resultMap> | </resultMap> | ||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| `id`,`tenant_id`,`parent_tenant_id`,`mch_id`,`sub_mch_id`,`api_key`,`notify_url`,`cert_path`,`type`,`share`,`rate`,`real_rate` | |||||
| `id`,`tenant_id`,`parent_tenant_id`,`mch_id`,`sub_mch_id`,`sub_app_id`,`api_key`,`notify_url`,`cert_path`, | |||||
| `type`,`share`,`rate`,`real_rate`, | |||||
| `service_id`,`pay_score_notify_url`,`api_v3_key`,`cert_serial_no`,`private_key_path`,`private_cert_path` | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||