Преглед изворни кода

businessCircle

release_toaliyun_real
xhxu пре 5 година
родитељ
комит
f8faaaad55
15 измењених фајлова са 1368 додато и 565 уклоњено
  1. +62
    -9
      mallinkCallback/src/main/java/com/iformall/controller/callback/AliPayController.java
  2. +229
    -229
      mallinkPublicApi/src/main/java/com/iformall/controller/UserThirdCircleOrderController.java
  3. +15
    -1
      mallinkService/src/main/java/com/iformall/config/BaseMyBatisConfiguration.java
  4. +2
    -27
      mallinkService/src/main/java/com/iformall/domain/po/BusinessCircleBase.java
  5. +37
    -0
      mallinkService/src/main/java/com/iformall/mapper/AliBusinessCircleOrderMapper.java
  6. +4
    -10
      mallinkService/src/main/java/com/iformall/mapper/WxThirdPartyOrdersMapper.java
  7. +47
    -0
      mallinkService/src/main/java/com/iformall/service/AliBusinessCircleOrderService.java
  8. +10
    -10
      mallinkService/src/main/java/com/iformall/service/WxThirdPartyOrdersService.java
  9. +218
    -0
      mallinkService/src/main/java/com/iformall/service/impl/AliBusinessCircleOrderServiceImpl.java
  10. +8
    -20
      mallinkService/src/main/java/com/iformall/service/impl/WxBusinessCircleOrderServiceImpl.java
  11. +3
    -1
      mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java
  12. +289
    -216
      mallinkService/src/main/java/com/iformall/service/impl/WxThirdPartyOrdersServiceImpl.java
  13. +203
    -0
      mallinkService/src/main/resources/mapper/AliBusinessCircleMapper.xml
  14. +183
    -0
      mallinkService/src/main/resources/mapper/AliBusinessCircleOrder.xml
  15. +58
    -42
      mallinkService/src/main/resources/mapper/WxThirdPartyOrdersMapper.xml

+ 62
- 9
mallinkCallback/src/main/java/com/iformall/controller/callback/AliPayController.java Прегледај датотеку

@@ -3,10 +3,8 @@ package com.iformall.controller.callback;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.iformall.controller.base.BaseController; import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.AliPayCUser;
import com.iformall.domain.po.WxMall;
import com.iformall.service.AliPayCUserService;
import com.iformall.service.WxMallService;
import com.iformall.domain.po.*;
import com.iformall.service.*;
import com.iformall.service.pay.alipay.AliPayUtil; import com.iformall.service.pay.alipay.AliPayUtil;
import com.iformall.service.pay.alipay.api.enums.EnumMemberCardConfig; import com.iformall.service.pay.alipay.api.enums.EnumMemberCardConfig;
import com.iformall.service.pay.alipay.api.result.UserAuthData; import com.iformall.service.pay.alipay.api.result.UserAuthData;
@@ -26,6 +24,10 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.Map; import java.util.Map;


@RestController @RestController
@@ -34,14 +36,23 @@ public class AliPayController 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-dd HH:mm:ss");


@Autowired @Autowired
private AliPayUtil alipayUtil; private AliPayUtil alipayUtil;

@Autowired
private WxMerchantService wxMerchantService;
@Autowired @Autowired
private WxMallService mallService; private WxMallService mallService;
@Autowired @Autowired
private AliPayCUserService aliPayCUserService; private AliPayCUserService aliPayCUserService;

@Autowired
AliBusinessCircleOrderService aliBusinessCircleOrderService;
private void writeResponse(HttpServletResponse response,String msg) { private void writeResponse(HttpServletResponse response,String msg) {
PrintWriter out; PrintWriter out;
@@ -209,13 +220,35 @@ public class AliPayController extends BaseController {
logger.error("alipay notify notify error. bizContent empity:"+paramMap); logger.error("alipay notify notify error. bizContent empity:"+paramMap);
}else { }else {
JSONObject jo = JSON.parseObject(bizContent); JSONObject jo = JSON.parseObject(bizContent);
String gmtPayment = jo.getString("gmt_payment");
String totalAmount = jo.getString("total_amount");//交易总金额
String gmtPayment = jo.getString("gmt_payment");//付款时间
Date endTime = sdf.parse(gmtPayment);
String totalAmount = jo.getString("total_amount");//交易总金额
int amount = new BigDecimal(totalAmount).multiply(new BigDecimal(100)).intValue();
String receiptAmount = jo.getString("receipt_amount");//商家实收金额 String receiptAmount = jo.getString("receipt_amount");//商家实收金额
int payAmount =new BigDecimal(receiptAmount).multiply(new BigDecimal(100)).intValue();
String mallStoreId = jo.getString("mall_store_id"); String mallStoreId = jo.getString("mall_store_id");
String buyerId = jo.getString("buyer_id"); String buyerId = jo.getString("buyer_id");
String tradeNo = jo.getString("trade_no");
}
String tradeNo = jo.getString("trade_no");

String mallId = jo.getString("mall_id");
String mallName = jo.getString("mall_name");

WxMerchant merchant = wxMerchantService.getById(Long.parseLong(mallStoreId));
if(merchant == null){return;}
AliBusinessCircleOrder aliBusinessCircleOrder = new AliBusinessCircleOrder();
aliBusinessCircleOrder.updateTenantInfo(merchant);
aliBusinessCircleOrder.setTransactionId(tradeNo);
aliBusinessCircleOrder.setAmount(amount);
aliBusinessCircleOrder.setPayAmount(payAmount);
aliBusinessCircleOrder.setTimeEnd(endTime);
aliBusinessCircleOrder.setBuyerId(buyerId);

aliBusinessCircleOrder.setMallId(mallId);
aliBusinessCircleOrder.setMallName(mallName);

aliBusinessCircleOrderService.createOrder(aliBusinessCircleOrder);

}
//退款成功 //退款成功
}else if ("alipay.business.mall.trade.refunded".equals(msgMethod)) { }else if ("alipay.business.mall.trade.refunded".equals(msgMethod)) {
String bizContent = (String) paramMap.get("biz_content"); String bizContent = (String) paramMap.get("biz_content");
@@ -224,10 +257,30 @@ public class AliPayController extends BaseController {
}else { }else {
JSONObject jo = JSON.parseObject(bizContent); JSONObject jo = JSON.parseObject(bizContent);
String gmtRefundPay = jo.getString("gmt_refund_pay");//退款时间 String gmtRefundPay = jo.getString("gmt_refund_pay");//退款时间
Date endTime = sdf.parse(gmtRefundPay);
String refundFee = jo.getString("refund_fee");//本次退款金额 String refundFee = jo.getString("refund_fee");//本次退款金额
int refundAmount = new BigDecimal(refundFee).multiply(new BigDecimal(100)).intValue();
String mallStoreId = jo.getString("mall_store_id"); String mallStoreId = jo.getString("mall_store_id");
String buyerId = jo.getString("buyer_id"); String buyerId = jo.getString("buyer_id");
String tradeNo = jo.getString("trade_no");
String tradeNo = jo.getString("trade_no");

String mallId = jo.getString("mall_id");
String mallName = jo.getString("mall_name");

WxMerchant merchant = wxMerchantService.getById(Long.parseLong(mallStoreId));
if(merchant == null){return;}
AliBusinessCircleOrder aliBusinessCircleOrder = new AliBusinessCircleOrder();
aliBusinessCircleOrder.updateTenantInfo(merchant);
aliBusinessCircleOrder.setTransactionId(tradeNo);
aliBusinessCircleOrder.setRefundAmount(refundAmount);
aliBusinessCircleOrder.setTimeEnd(endTime);
aliBusinessCircleOrder.setBuyerId(buyerId);

aliBusinessCircleOrder.setMallId(mallId);
aliBusinessCircleOrder.setMallName(mallName);

aliBusinessCircleOrderService.insertRefundNoticeOrder(aliBusinessCircleOrder);

} }
} }
} }


+ 229
- 229
mallinkPublicApi/src/main/java/com/iformall/controller/UserThirdCircleOrderController.java Прегледај датотеку

@@ -1,229 +1,229 @@
//package com.iformall.controller;
//
//import com.iformall.common.ErrorCode;
//import com.iformall.common.ResultData;
//import com.iformall.domain.po.WxThirdPartyOrders;
//import com.iformall.enums.EnumThirdOrderType;
//import com.iformall.exception.MallinkException;
//import com.iformall.service.WxThirdPartyOrdersService;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import org.apache.commons.lang3.StringUtils;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//import java.text.ParseException;
//import java.text.SimpleDateFormat;
//import java.util.Date;
//import java.util.Map;
//
//@RestController
//@RequestMapping("api/thirdCircle")
//@Api(description = "会员交易相关接口")
//public class UserThirdCircleOrderController extends BaseController {
//
// private final Logger logger = LoggerFactory.getLogger(this.getClass());
//
// private final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//
//
// @Autowired
// WxThirdPartyOrdersService thirdPartyOrdersService;
//
// /**
// *
// * @param
// * @return
// */
// @PostMapping("/order")
// @ApiOperation(value = "订单", notes = "")
// public ResultData createOrder(@RequestBody Map<String,Object> map) {
// logger.info("UserThirdCircleOrderController >>>>>>>>>>>> createOrder >>>>>>>>>>>>>"+map.toString());
//
// String transactionId = (String) map.get("transactionId");//***订单Id
// Long shopNumber = (Long) map.get("shopNumber");//***门店唯一标识 对应双方平台门店
// String shopName = (String) map.get("shopName");//门店名称
// Long userNumber = (Long) map.get("userNumber");//***会员Id
// String userPhone = (String) map.get("userPhone");//会员手机号
// String timeEnd = (String) map.get("timeEnd");//***付款时间(yyyy-MM-dd HH:mm:ss)
// Integer amount = (Integer) map.get("amount");//***付款金额(分)
// String summary = (String) map.get("summary");//付款摘要
//
// if(StringUtils.isBlank(transactionId)){
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"transactionId为空");
// }
// if(shopNumber == null){
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"shopNumber为空");
// }
// if(userNumber == null){
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"userNumber为空");
// }
// if(StringUtils.isNotBlank(userPhone) && !userPhone.matches("^1[0-9]{10}$")){
// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"userPhone格式不正确");
// }
// if(timeEnd == null){
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"timeEnd为空");
// }
// Date timeEndDate = null;
// try {
// timeEndDate = sdf.parse(timeEnd);
// } catch (ParseException e) {
// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"timeEnd格式不正确");
// }
// if(amount == null){
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"amount为空");
// }
//
// WxThirdPartyOrders thirdPartyOrders = new WxThirdPartyOrders();
// thirdPartyOrders.updateTenantInfo(getTenantInfo());
// thirdPartyOrders.setSourceAppId(getAppId());
//
// thirdPartyOrders.setTransactionId(transactionId);
// thirdPartyOrders.setShopNumber(String.valueOf(shopNumber));
// thirdPartyOrders.setShopName(shopName);
// thirdPartyOrders.setUserNumber(String.valueOf(userNumber));
// thirdPartyOrders.setUserPhone(userPhone);
// thirdPartyOrders.setTimeEnd(timeEndDate);
// thirdPartyOrders.setAmount(amount);
// thirdPartyOrders.setSummary(summary);
// try{
// thirdPartyOrdersService.createOrder(thirdPartyOrders);
// }catch(MallinkException e){
// logger.error(e.getMessage());
// return new ResultData(e.getErrorCode(), e.getMessage());
// }catch(Exception e){
// e.printStackTrace();
// return new ResultData(ErrorCode.SYS_SERVER_ERROR);
// }
//
// return new ResultData();
// }
//
// /**
// *
// * @param
// * @return
// */
// @PostMapping("/orderRefund")
// @ApiOperation(value = "退款", notes = "")
// public ResultData orderRefund(@RequestBody Map<String,Object> map) {
// logger.info("UserThirdCircleOrderController >>>>>>>>>>>> orderRefund >>>>>>>>>>>>>"+map.toString());
//
// String transactionId = (String) map.get("transactionId");//***订单Id
// String refundTime = (String) map.get("refundTime");//***退款时间(yyyy-MM-dd HH:mm:ss)
// String refundSummary = (String) map.get("refundSummary");//退款摘要
// Integer refundAmount = (Integer) map.get("refundAmount");//退款金额(分)
// String refundId = (String) map.get("refundId");//退款Id
//
// if(StringUtils.isBlank(transactionId)){
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"transactionId为空");
// }
// if(refundTime == null){
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"refundTime为空");
// }
// Date refundTimeDate = null;
// try {
// refundTimeDate = sdf.parse(refundTime);
// } catch (ParseException e) {
// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"timeEnd格式不正确");
// }
//
// WxThirdPartyOrders thirdPartyOrders = new WxThirdPartyOrders();
// thirdPartyOrders.updateTenantInfo(getTenantInfo());
// thirdPartyOrders.setSourceAppId(getAppId());
// thirdPartyOrders.setSourceType(EnumThirdOrderType.RMB_PAY.getCode());
//
// thirdPartyOrders.setTransactionId(transactionId);
// thirdPartyOrders.setRefundTime(refundTimeDate);
// thirdPartyOrders.setRefundSummary(refundSummary);
// thirdPartyOrders.setRefundAmount(refundAmount);
// thirdPartyOrders.setRefundId(refundId);
//
// try{
// thirdPartyOrdersService.updateRefundOrder(thirdPartyOrders);
// }catch(MallinkException e){
// logger.error(e.getMessage());
// return new ResultData(e.getErrorCode(), e.getMessage());
// }catch(Exception e){
// e.printStackTrace();
// return new ResultData(ErrorCode.SYS_SERVER_ERROR);
// }
//
// return new ResultData();
// }
//
//
// /**
// *
// * @param
// * @return
// */
// @PostMapping("/pointDeduction")
// @ApiOperation(value = "积分抵扣", notes = "")
// public ResultData pointDeduction(@RequestBody Map<String,Object> map) {
// logger.info("UserThirdCircleOrderController >>>>>>>>>>>> pointDeduction >>>>>>>>>>>>>"+map.toString());
//
// String transactionId = (String) map.get("transactionId");//***订单Id
// Long shopNumber = (Long) map.get("shopNumber");//***门店唯一标识 对应双方平台门店
// String shopName = (String) map.get("shopName");//门店名称
// Long userNumber = (Long) map.get("userNumber");//***会员Id
// String userPhone = (String) map.get("userPhone");//会员手机号
// String timeEnd = (String) map.get("timeEnd");//***抵扣时间
// Integer amount = (Integer) map.get("amount");//***积分数量
// String summary = (String) map.get("summary");//付款摘要
//
// if(StringUtils.isBlank(transactionId)){
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"transactionId为空");
// }
// if(shopNumber == null){
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"shopNumber为空");
// }
// if(userNumber == null){
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"userNumber为空");
// }
// if(StringUtils.isNotBlank(userPhone) && !userPhone.matches("^1[0-9]{10}$")){
// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"userPhone格式不正确");
// }
// if(timeEnd == null){
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"timeEnd为空");
// }
// Date timeEndDate = null;
// try {
// timeEndDate = sdf.parse(timeEnd);
// } catch (ParseException e) {
// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"timeEnd格式不正确");
// }
// if(amount == null){
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"amount为空");
// }
//
// WxThirdPartyOrders thirdPartyOrders = new WxThirdPartyOrders();
// thirdPartyOrders.updateTenantInfo(getTenantInfo());
// thirdPartyOrders.setSourceAppId(getAppId());
//
// thirdPartyOrders.setTransactionId(transactionId);
// thirdPartyOrders.setShopNumber(String.valueOf(shopNumber));
// thirdPartyOrders.setShopName(shopName);
// thirdPartyOrders.setUserNumber(String.valueOf(userNumber));
// thirdPartyOrders.setUserPhone(userPhone);
// thirdPartyOrders.setTimeEnd(timeEndDate);
// thirdPartyOrders.setAmount(amount);
// thirdPartyOrders.setSummary(summary);
// try{
// thirdPartyOrdersService.pointDeduction(thirdPartyOrders);
// return new ResultData();
// }catch(MallinkException e){
// logger.error(e.getMessage());
// return new ResultData(e.getErrorCode(), e.getMessage());
// }catch(Exception e){
// e.printStackTrace();
// return new ResultData(ErrorCode.SYS_SERVER_ERROR);
// }
// }
//
//}
package com.iformall.controller;
import com.iformall.common.ErrorCode;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxThirdPartyOrders;
import com.iformall.enums.EnumThirdOrderType;
import com.iformall.exception.MallinkException;
import com.iformall.service.WxThirdPartyOrdersService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
@RestController
@RequestMapping("api/thirdCircle")
@Api(description = "会员交易相关接口")
public class UserThirdCircleOrderController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
private final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@Autowired
WxThirdPartyOrdersService thirdPartyOrdersService;
/**
*
* @param
* @return
*/
@PostMapping("/order")
@ApiOperation(value = "订单", notes = "")
public ResultData createOrder(@RequestBody Map<String,Object> map) {
logger.info("UserThirdCircleOrderController >>>>>>>>>>>> createOrder >>>>>>>>>>>>>"+map.toString());
String transactionId = (String) map.get("transactionId");//***订单Id
Long shopNumber = (Long) map.get("shopNumber");//***门店唯一标识 对应双方平台门店
String shopName = (String) map.get("shopName");//门店名称
Long userNumber = (Long) map.get("userNumber");//***会员Id
String userPhone = (String) map.get("userPhone");//会员手机号
String timeEnd = (String) map.get("timeEnd");//***付款时间(yyyy-MM-dd HH:mm:ss)
Integer amount = (Integer) map.get("amount");//***付款金额(分)
String summary = (String) map.get("summary");//付款摘要
if(StringUtils.isBlank(transactionId)){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"transactionId为空");
}
if(shopNumber == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"shopNumber为空");
}
if(userNumber == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"userNumber为空");
}
if(StringUtils.isNotBlank(userPhone) && !userPhone.matches("^1[0-9]{10}$")){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"userPhone格式不正确");
}
if(timeEnd == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"timeEnd为空");
}
Date timeEndDate = null;
try {
timeEndDate = sdf.parse(timeEnd);
} catch (ParseException e) {
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"timeEnd格式不正确");
}
if(amount == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"amount为空");
}
WxThirdPartyOrders thirdPartyOrders = new WxThirdPartyOrders();
thirdPartyOrders.updateTenantInfo(getTenantInfo());
thirdPartyOrders.setSourceAppId(getAppId());
thirdPartyOrders.setTransactionId(transactionId);
thirdPartyOrders.setShopNumber(String.valueOf(shopNumber));
thirdPartyOrders.setShopName(shopName);
thirdPartyOrders.setUserNumber(String.valueOf(userNumber));
thirdPartyOrders.setUserPhone(userPhone);
thirdPartyOrders.setTimeEnd(timeEndDate);
thirdPartyOrders.setAmount(amount);
thirdPartyOrders.setSummary(summary);
try{
thirdPartyOrdersService.createOrder(thirdPartyOrders);
}catch(MallinkException e){
logger.error(e.getMessage());
return new ResultData(e.getErrorCode(), e.getMessage());
}catch(Exception e){
e.printStackTrace();
return new ResultData(ErrorCode.SYS_SERVER_ERROR);
}
return new ResultData();
}
/**
*
* @param
* @return
*/
@PostMapping("/orderRefund")
@ApiOperation(value = "退款", notes = "")
public ResultData orderRefund(@RequestBody Map<String,Object> map) {
logger.info("UserThirdCircleOrderController >>>>>>>>>>>> orderRefund >>>>>>>>>>>>>"+map.toString());
String transactionId = (String) map.get("transactionId");//***订单Id
String refundTime = (String) map.get("refundTime");//***退款时间(yyyy-MM-dd HH:mm:ss)
String refundSummary = (String) map.get("refundSummary");//退款摘要
Integer refundAmount = (Integer) map.get("refundAmount");//退款金额(分)
String refundId = (String) map.get("refundId");//退款Id
if(StringUtils.isBlank(transactionId)){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"transactionId为空");
}
if(refundTime == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"refundTime为空");
}
Date refundTimeDate = null;
try {
refundTimeDate = sdf.parse(refundTime);
} catch (ParseException e) {
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"timeEnd格式不正确");
}
WxThirdPartyOrders thirdPartyOrders = new WxThirdPartyOrders();
thirdPartyOrders.updateTenantInfo(getTenantInfo());
thirdPartyOrders.setSourceAppId(getAppId());
thirdPartyOrders.setSourceType(EnumThirdOrderType.RMB_PAY.getCode());
thirdPartyOrders.setTransactionId(transactionId);
thirdPartyOrders.setEndTime(refundTimeDate);
thirdPartyOrders.setSummary(refundSummary);
thirdPartyOrders.setRefundAmount(refundAmount);
thirdPartyOrders.setRefundId(refundId);
try{
thirdPartyOrdersService.insertRefundNoticeOrder(thirdPartyOrders);
}catch(MallinkException e){
logger.error(e.getMessage());
return new ResultData(e.getErrorCode(), e.getMessage());
}catch(Exception e){
e.printStackTrace();
return new ResultData(ErrorCode.SYS_SERVER_ERROR);
}
return new ResultData();
}
/**
*
* @param
* @return
*/
@PostMapping("/pointDeduction")
@ApiOperation(value = "积分抵扣", notes = "")
public ResultData pointDeduction(@RequestBody Map<String,Object> map) {
logger.info("UserThirdCircleOrderController >>>>>>>>>>>> pointDeduction >>>>>>>>>>>>>"+map.toString());
String transactionId = (String) map.get("transactionId");//***订单Id
Long shopNumber = (Long) map.get("shopNumber");//***门店唯一标识 对应双方平台门店
String shopName = (String) map.get("shopName");//门店名称
Long userNumber = (Long) map.get("userNumber");//***会员Id
String userPhone = (String) map.get("userPhone");//会员手机号
String timeEnd = (String) map.get("timeEnd");//***抵扣时间
Integer amount = (Integer) map.get("amount");//***积分数量
String summary = (String) map.get("summary");//付款摘要
if(StringUtils.isBlank(transactionId)){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"transactionId为空");
}
if(shopNumber == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"shopNumber为空");
}
if(userNumber == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"userNumber为空");
}
if(StringUtils.isNotBlank(userPhone) && !userPhone.matches("^1[0-9]{10}$")){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"userPhone格式不正确");
}
if(timeEnd == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"timeEnd为空");
}
Date timeEndDate = null;
try {
timeEndDate = sdf.parse(timeEnd);
} catch (ParseException e) {
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"timeEnd格式不正确");
}
if(amount == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"amount为空");
}
WxThirdPartyOrders thirdPartyOrders = new WxThirdPartyOrders();
thirdPartyOrders.updateTenantInfo(getTenantInfo());
thirdPartyOrders.setSourceAppId(getAppId());
thirdPartyOrders.setTransactionId(transactionId);
thirdPartyOrders.setShopNumber(String.valueOf(shopNumber));
thirdPartyOrders.setShopName(shopName);
thirdPartyOrders.setUserNumber(String.valueOf(userNumber));
thirdPartyOrders.setUserPhone(userPhone);
thirdPartyOrders.setTimeEnd(timeEndDate);
thirdPartyOrders.setAmount(amount);
thirdPartyOrders.setSummary(summary);
try{
thirdPartyOrdersService.pointDeduction(thirdPartyOrders);
return new ResultData();
}catch(MallinkException e){
logger.error(e.getMessage());
return new ResultData(e.getErrorCode(), e.getMessage());
}catch(Exception e){
e.printStackTrace();
return new ResultData(ErrorCode.SYS_SERVER_ERROR);
}
}
}

+ 15
- 1
mallinkService/src/main/java/com/iformall/config/BaseMyBatisConfiguration.java Прегледај датотеку

@@ -103,7 +103,21 @@ public class BaseMyBatisConfiguration {
wxBusinessCircleOrderSharding.setCount(100); wxBusinessCircleOrderSharding.setCount(100);
wxBusinessCircleOrderSharding.setRule(EnumShardingRule.HASH.getCode()); wxBusinessCircleOrderSharding.setRule(EnumShardingRule.HASH.getCode());
shardingList.add(wxBusinessCircleOrderSharding); shardingList.add(wxBusinessCircleOrderSharding);

ShardingSphere aliBusinessCircleOrderSharding = new ShardingSphere();
aliBusinessCircleOrderSharding.setColumn("tenant_id");
aliBusinessCircleOrderSharding.setTableName("ali_business_circle_order");
aliBusinessCircleOrderSharding.setCount(100);
aliBusinessCircleOrderSharding.setRule(EnumShardingRule.HASH.getCode());
shardingList.add(aliBusinessCircleOrderSharding);

ShardingSphere wxThirdPartyOrdersSharding = new ShardingSphere();
wxThirdPartyOrdersSharding.setColumn("tenant_id");
wxThirdPartyOrdersSharding.setTableName("wx_third_party_orders");
wxThirdPartyOrdersSharding.setCount(100);
wxThirdPartyOrdersSharding.setRule(EnumShardingRule.HASH.getCode());
shardingList.add(wxThirdPartyOrdersSharding);

ShardingSphere wxOrderSharding = new ShardingSphere(); ShardingSphere wxOrderSharding = new ShardingSphere();
wxOrderSharding.setColumn("tenant_id"); wxOrderSharding.setColumn("tenant_id");
wxOrderSharding.setTableName("wx_order"); wxOrderSharding.setTableName("wx_order");


+ 2
- 27
mallinkService/src/main/java/com/iformall/domain/po/BusinessCircleBase.java Прегледај датотеку

@@ -36,24 +36,6 @@ public class BusinessCircleBase extends TenantEntity {
@io.swagger.annotations.ApiModelProperty(value="商圈支付结果通知回调摘要",name="summary") @io.swagger.annotations.ApiModelProperty(value="商圈支付结果通知回调摘要",name="summary")
private String 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") @io.swagger.annotations.ApiModelProperty(value="交易完成时间",name="timeEnd")
private Date timeEnd; private Date timeEnd;


@@ -82,19 +64,16 @@ public class BusinessCircleBase extends TenantEntity {
@io.swagger.annotations.ApiModelProperty(value="支付订单号",name="transactionId") @io.swagger.annotations.ApiModelProperty(value="支付订单号",name="transactionId")
private String transactionId; private String transactionId;


@io.swagger.annotations.ApiModelProperty(value="手动提交积分标记,自动提交时无该字段,用于区分用户手动申请后推送的积分",name="commitTag")
private String commitTag;

@io.swagger.annotations.ApiModelProperty(value="创建时间",name="createTime") @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createTime")
private Date createTime; private Date createTime;


@io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateTime") @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateTime")
private Date updateTime; private Date updateTime;


@io.swagger.annotations.ApiModelProperty(value="门店Id,与wx_shop_number对齐",name="merchantId")
@io.swagger.annotations.ApiModelProperty(value="门店Id,与第三方对齐",name="merchantId")
private Long merchantId; private Long merchantId;


@io.swagger.annotations.ApiModelProperty(value="c端会员id,与openid对齐",name="cUserId")
@io.swagger.annotations.ApiModelProperty(value="c端会员id,与第三方对齐",name="cUserId")
private Long cUserId; private Long cUserId;


@io.swagger.annotations.ApiModelProperty(value="是否获得积分(1:是,0:否)",name="earnPoints") @io.swagger.annotations.ApiModelProperty(value="是否获得积分(1:是,0:否)",name="earnPoints")
@@ -106,10 +85,6 @@ public class BusinessCircleBase extends TenantEntity {
@io.swagger.annotations.ApiModelProperty(value="积分更新时间(新增)",name="increasedPoints") @io.swagger.annotations.ApiModelProperty(value="积分更新时间(新增)",name="increasedPoints")
private Date pointsUpdateTime; private Date pointsUpdateTime;


@io.swagger.annotations.ApiModelProperty(value="是否积分同步(1:是,0:否)",name="isPointsNotify")
private Integer isPointsNotify;


@io.swagger.annotations.ApiModelProperty(value="是否退款(1:是,0:否)",name="isRefund") @io.swagger.annotations.ApiModelProperty(value="是否退款(1:是,0:否)",name="isRefund")
private Integer isRefund; private Integer isRefund;




+ 37
- 0
mallinkService/src/main/java/com/iformall/mapper/AliBusinessCircleOrderMapper.java Прегледај датотеку

@@ -0,0 +1,37 @@
package com.iformall.mapper;


import com.iformall.common.CommonMapper;
import com.iformall.domain.po.AliBusinessCircleOrder;

import java.util.List;


public interface AliBusinessCircleOrderMapper extends CommonMapper<AliBusinessCircleOrder, Long> {
List<AliBusinessCircleOrder> findList(AliBusinessCircleOrder record);

AliBusinessCircleOrder getById(AliBusinessCircleOrder record);

AliBusinessCircleOrder getOrderByTransactionId(AliBusinessCircleOrder record);
List<AliBusinessCircleOrder> getRefundOrderByTransactionId(AliBusinessCircleOrder record);

/**
* 成功通知新建
* @param record
*/
void insertNoticeOrder(AliBusinessCircleOrder record);

/**
* 加积分
* @param record
*/
void updatePoints(AliBusinessCircleOrder record);

/**
* 退款
* @param record
*/
void insertRefundNoticeOrder(AliBusinessCircleOrder record);

}

+ 4
- 10
mallinkService/src/main/java/com/iformall/mapper/WxThirdPartyOrdersMapper.java Прегледај датотеку

@@ -13,7 +13,8 @@ public interface WxThirdPartyOrdersMapper extends CommonMapper<WxThirdPartyOrder


WxThirdPartyOrders getById(WxThirdPartyOrders record); WxThirdPartyOrders getById(WxThirdPartyOrders record);


WxThirdPartyOrders getByTransactionId(WxThirdPartyOrders record);
WxThirdPartyOrders getOrderByTransactionId(WxThirdPartyOrders record);
List<WxThirdPartyOrders> getRefundOrderByTransactionId(WxThirdPartyOrders record);


/** /**
* 成功通知新建 * 成功通知新建
@@ -25,19 +26,12 @@ public interface WxThirdPartyOrdersMapper extends CommonMapper<WxThirdPartyOrder
* 加积分 * 加积分
* @param record * @param record
*/ */
void updateAddPoints(WxThirdPartyOrders record);
void updatePoints(WxThirdPartyOrders record);


/** /**
* 退款 * 退款
* @param record * @param record
*/ */
void updateRefundNoticeOrder(WxThirdPartyOrders record);

/**
* 退积分
* @param record
*/
void updateRefundPoints(WxThirdPartyOrders record);

void insertRefundNoticeOrder(WxThirdPartyOrders record);


} }

+ 47
- 0
mallinkService/src/main/java/com/iformall/service/AliBusinessCircleOrderService.java Прегледај датотеку

@@ -0,0 +1,47 @@
package com.iformall.service;

import com.github.pagehelper.PageInfo;
import com.iformall.domain.po.AliBusinessCircleOrder;

import java.util.List;

public interface AliBusinessCircleOrderService {


/**
* 根据实体查询分页列表
*
* @param record
* @param pageIndex
* @param pageSize
* @return
*/
PageInfo<AliBusinessCircleOrder> listAsPage(AliBusinessCircleOrder record, Integer pageIndex, Integer pageSize);

/**
* id+tenantId
* @param
* @return
*/
AliBusinessCircleOrder getById(Long id, String tenantId);

/**
* transactionId+tenantId
* @param
* @return
*/
AliBusinessCircleOrder getOrderByTransactionId(String transactionId, String tenantId);
List<AliBusinessCircleOrder> getRefundOrderByTransactionId(String transactionId, String tenantId);


void createOrder(AliBusinessCircleOrder record);

void insertRefundNoticeOrder(AliBusinessCircleOrder record);

/**
* 积分
* @param record
*/
void updatePoints(AliBusinessCircleOrder record);

}

+ 10
- 10
mallinkService/src/main/java/com/iformall/service/WxThirdPartyOrdersService.java Прегледај датотеку

@@ -1,7 +1,11 @@
package com.iformall.service; package com.iformall.service;


import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.iformall.domain.po.WxBusinessCircleOrder;
import com.iformall.domain.po.WxThirdPartyOrders; import com.iformall.domain.po.WxThirdPartyOrders;
import com.iformall.enums.EnumThirdOrderType;

import java.util.List;


public interface WxThirdPartyOrdersService { public interface WxThirdPartyOrdersService {


@@ -28,23 +32,19 @@ public interface WxThirdPartyOrdersService {
* @param * @param
* @return * @return
*/ */
WxThirdPartyOrders getByTransactionId(String transactionId, String tenantId);
WxThirdPartyOrders getOrderByTransactionId(EnumThirdOrderType orderType, String transactionId, String tenantId);
List<WxThirdPartyOrders> getRefundOrderByTransactionId(EnumThirdOrderType orderType, String transactionId, String tenantId);


void createOrder(WxThirdPartyOrders record);


void updateRefundOrder(WxThirdPartyOrders record);
void createOrder(WxThirdPartyOrders record);


/**
* 加积分
* @param record
*/
void updateAddPoints(WxThirdPartyOrders record);
void insertRefundNoticeOrder(WxThirdPartyOrders record);


/** /**
* 退积分
* 积分
* @param record * @param record
*/ */
void updateRefundPoints(WxThirdPartyOrders record);
void updatePoints(WxThirdPartyOrders record);


/** /**
* 积分抵扣 * 积分抵扣


+ 218
- 0
mallinkService/src/main/java/com/iformall/service/impl/AliBusinessCircleOrderServiceImpl.java Прегледај датотеку

@@ -0,0 +1,218 @@
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.*;
import com.iformall.enums.EnumBusiness;
import com.iformall.enums.EnumScoreType;
import com.iformall.enums.EnumUserType;
import com.iformall.enums.EnumYesOrNo;
import com.iformall.mapper.AliBusinessCircleOrderMapper;
import com.iformall.service.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

@Service
public class AliBusinessCircleOrderServiceImpl implements AliBusinessCircleOrderService {

private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
AliBusinessCircleOrderMapper aliBusinessCircleOrderMapper;

@Autowired
WxMerchantService wxMerchantService;

@Autowired
AliPayCUserService aliPayCUserService;

@Autowired
WxCUserBasicInfoService wxCUserBasicInfoService;

@Autowired
WxCreditHistoryService creditHistoryService;


@Override
public PageInfo<AliBusinessCircleOrder> listAsPage(AliBusinessCircleOrder record, Integer pageIndex, Integer pageSize) {
return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> aliBusinessCircleOrderMapper.findList(record));
}

@Override
public AliBusinessCircleOrder getById(Long id, String tenantId) {
AliBusinessCircleOrder recordQ = new AliBusinessCircleOrder();
recordQ.setId(id);
recordQ.setTenantId(tenantId);
return aliBusinessCircleOrderMapper.getById(recordQ);
}

@Override
public AliBusinessCircleOrder getOrderByTransactionId(String transactionId, String tenantId) {
AliBusinessCircleOrder recordQ = new AliBusinessCircleOrder();
recordQ.setTransactionId(transactionId);
recordQ.setTenantId(tenantId);
return aliBusinessCircleOrderMapper.getOrderByTransactionId(recordQ);
}

@Override
public List<AliBusinessCircleOrder> getRefundOrderByTransactionId(String transactionId, String tenantId) {
AliBusinessCircleOrder recordQ = new AliBusinessCircleOrder();
recordQ.setTransactionId(transactionId);
recordQ.setTenantId(tenantId);
return aliBusinessCircleOrderMapper.getRefundOrderByTransactionId(recordQ);
}

@Override
public void createOrder(AliBusinessCircleOrder record) {
AliBusinessCircleOrder byTransactionId = this.getOrderByTransactionId(record.getTransactionId(),record.getTenantId());
if(byTransactionId != null){
logger.error("--Ali商圈付款--订单消息已存在---byTransactionId="+byTransactionId.getTransactionId());
}else{
Date now = new Date();
final IdWorker idWorker = IdWorker.get();
record.setId(idWorker.nextId());
record.setCreateTime(now);
record.setUpdateTime(now);

//TODO 第三方获取门店(标识可能发生变化)
WxMerchant wxMerchant = wxMerchantService.getById(Long.parseLong(record.getMallStoreId()));
if(wxMerchant != null){
record.setMerchantId(wxMerchant.getId());
}else{
logger.error("--Ali商圈付款通知消息未找到门店--mallStoreId="+record.getMallStoreId());
}
AliPayCUser userQ = new AliPayCUser();
userQ.updateTenantInfo(record);
userQ.setId(Long.parseLong(record.getBuyerId()));
AliPayCUser aliUser = aliPayCUserService.getByAliPayUserId(userQ);
WxCUserBasicInfo infoByPhone = wxCUserBasicInfoService.findInfoByPhone(aliUser, aliUser.getPhone());

if(infoByPhone != null ){
record.setCUserId(infoByPhone.getId());
}else{
logger.error("--Ali商圈付款通知消息未找到会员--aliUserId="+record.getBuyerId());
}
aliBusinessCircleOrderMapper.insertNoticeOrder(record);

if(record.getCUserId() == null){
return;
}
Integer businessId = EnumBusiness.BUSINESS_ID6.getCode();
if(wxMerchant != null){
businessId = wxMerchant.getBusinessId();
}
WxCreditHistory creditHistory = new WxCreditHistory();
creditHistory.setTenantId(record.getFinalTenantId());
creditHistory.setOperatorType(EnumUserType.ALI_CIRCLE.getCode());
creditHistory.setOperatorId(record.getCUserId());
creditHistory.setCUserId(record.getCUserId());
creditHistory.setCreateDate(now);
creditHistory.setCouponId(record.getId());
creditHistory.setBusinessId(businessId);
creditHistory.setMerchantId(record.getMerchantId());
creditHistory.setCreditType(EnumScoreType.CONSUMPTION.getCode());
creditHistory.setSpend(record.getPayAmount());
creditHistory.setChangePurpose("Ali商圈消费:消费商户["+record.getMallName()+"] ("+record.getPayAmountStr()+"元) ");
creditHistory = creditHistoryService.saveOrUpdate(creditHistory,record.getTenantId());
Integer creditNum = 0;
if (creditHistory.getCreditNum() != null) {
creditNum = creditHistory.getCreditNum();
}
if(creditNum == 0){
return;
}
record.setIncreasedPoints(creditNum);
record.setPointsUpdateTime(creditHistory.getCreateDate());
this.updatePoints(record);
}
}

@Override
public void insertRefundNoticeOrder(AliBusinessCircleOrder record) {
AliBusinessCircleOrder order = this.getOrderByTransactionId(record.getTransactionId(),record.getTenantId());
if(order == null){
logger.error("--Ali商圈退款--付款消息未找到--transactionId="+record.getTransactionId());
}else{
List<AliBusinessCircleOrder> refundOrders = this.getRefundOrderByTransactionId(record.getTransactionId(),record.getTenantId());
Integer amount = order.getPayAmount();
Integer increasedPoints = order.getIncreasedPoints();
Integer refundAmount = 0;
Integer refundIncreasedPoints = 0;

if(refundOrders != null && refundOrders.size()>0){
for (AliBusinessCircleOrder ro:refundOrders) {
refundAmount += ro.getRefundAmount();
refundIncreasedPoints += ro.getIncreasedPoints();
}
}
if(refundAmount >= amount){
logger.error("--Ali商圈退款--已经退款--transactionId="+record.getTransactionId());
}else if((refundAmount + record.getRefundAmount()) > amount ){
logger.error("--Ali商圈退款--退款金额超限--transactionId="+record.getTransactionId());
}else{
Date now = new Date();
final IdWorker idWorker = IdWorker.get();
record.setId(idWorker.nextId());
record.setCreateTime(now);
record.setUpdateTime(now);

record.setCUserId(order.getCUserId());
record.setMerchantId(order.getMerchantId());
aliBusinessCircleOrderMapper.insertRefundNoticeOrder(record);

if(order.getEarnPoints().equals(EnumYesOrNo.YES.getCode())){
WxCreditHistory creditHistory = new WxCreditHistory();
creditHistory.setTenantId(record.getFinalTenantId());
creditHistory.setOperatorType(EnumUserType.ALI_CIRCLE.getCode());
creditHistory.setOperatorId(record.getCUserId());
creditHistory.setCUserId(record.getCUserId());
creditHistory.setCreateDate(new Date());
creditHistory.setCouponId(record.getId());
creditHistory.setMerchantId(record.getMerchantId());
creditHistory.setCreditType(EnumScoreType.REFUND_CONSUMPTION.getCode());
int points = 0;
if((refundAmount + record.getRefundAmount()) == amount){
points = increasedPoints - refundIncreasedPoints;
}else{
points = new BigDecimal(order.getIncreasedPoints())
.divide(new BigDecimal(order.getPayAmount()),2,BigDecimal.ROUND_HALF_UP)
.multiply(new BigDecimal(record.getRefundAmount()))
.intValue();
}

creditHistory.setCreditNum(points);
creditHistory.setSpend(0-record.getRefundAmount());
creditHistory.setChangePurpose("Ali商圈消费退款:商户["+record.getMallName()+"] ("+record.getRefundAmountStr()+"元) ");
creditHistory = creditHistoryService.saveOrUpdate(creditHistory,record.getTenantId());
Integer creditNum = 0;
if (creditHistory.getCreditNum() != null) {
creditNum = creditHistory.getCreditNum();
}
if(creditNum == 0){
return;
}

record.setIncreasedPoints(creditNum);
record.setPointsUpdateTime(creditHistory.getCreateDate());
this.updatePoints(record);
}
}
}
}


@Override
public void updatePoints(AliBusinessCircleOrder record) {
record.setUpdateTime(new Date());
aliBusinessCircleOrderMapper.updatePoints(record);
}


}

+ 8
- 20
mallinkService/src/main/java/com/iformall/service/impl/WxBusinessCircleOrderServiceImpl.java Прегледај датотеку

@@ -9,7 +9,6 @@ import com.iformall.domain.po.WxCreditHistory;
import com.iformall.domain.po.WxMerchant; import com.iformall.domain.po.WxMerchant;
import com.iformall.enums.*; import com.iformall.enums.*;
import com.iformall.mapper.WxBusinessCircleOrderMapper; import com.iformall.mapper.WxBusinessCircleOrderMapper;
import com.iformall.mq.MqBaseProducer;
import com.iformall.service.*; import com.iformall.service.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -17,19 +16,14 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;


import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Locale;


@Service @Service
public class WxBusinessCircleOrderServiceImpl implements WxBusinessCircleOrderService { public class WxBusinessCircleOrderServiceImpl implements WxBusinessCircleOrderService {


private final Logger logger = LoggerFactory.getLogger(this.getClass()); private final Logger logger = LoggerFactory.getLogger(this.getClass());


private final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'+'mm:ss", Locale.CHINA);


@Autowired @Autowired
WxBusinessCircleOrderMapper wxBusinessCircleOrderMapper; WxBusinessCircleOrderMapper wxBusinessCircleOrderMapper;


@@ -42,15 +36,9 @@ public class WxBusinessCircleOrderServiceImpl implements WxBusinessCircleOrderSe
@Autowired @Autowired
WxCreditHistoryService creditHistoryService; WxCreditHistoryService creditHistoryService;


@Autowired
WxPayAccountService wxPayAccountService;

@Autowired @Autowired
WxCallBackService wxCallBackService; WxCallBackService wxCallBackService;


@Autowired
MqBaseProducer mqBaseProducer;



@Override @Override
public PageInfo<WxBusinessCircleOrder> listAsPage(WxBusinessCircleOrder record, Integer pageIndex, Integer pageSize) { public PageInfo<WxBusinessCircleOrder> listAsPage(WxBusinessCircleOrder record, Integer pageIndex, Integer pageSize) {
@@ -85,7 +73,7 @@ public class WxBusinessCircleOrderServiceImpl implements WxBusinessCircleOrderSe
public void createOrder(WxBusinessCircleOrder record) { public void createOrder(WxBusinessCircleOrder record) {
WxBusinessCircleOrder byTransactionId = this.getOrderByTransactionId(record.getTransactionId(),record.getTenantId()); WxBusinessCircleOrder byTransactionId = this.getOrderByTransactionId(record.getTransactionId(),record.getTenantId());
if(byTransactionId != null){ if(byTransactionId != null){
logger.error("--商圈付款--订单消息已存在---byTransactionId="+byTransactionId.getTransactionId());
logger.error("--Wx商圈付款--订单消息已存在---byTransactionId="+byTransactionId.getTransactionId());
}else{ }else{
Date now = new Date(); Date now = new Date();
final IdWorker idWorker = IdWorker.get(); final IdWorker idWorker = IdWorker.get();
@@ -98,7 +86,7 @@ public class WxBusinessCircleOrderServiceImpl implements WxBusinessCircleOrderSe
if(wxMerchant != null){ if(wxMerchant != null){
record.setMerchantId(wxMerchant.getId()); record.setMerchantId(wxMerchant.getId());
}else{ }else{
logger.error("--商圈付款通知消息未找到门店--shopName="+record.getWxShopName()+"&shopNumber="+record.getWxShopNumber());
logger.error("--Wx商圈付款通知消息未找到门店--shopName="+record.getWxShopName()+"&shopNumber="+record.getWxShopNumber());
} }
WxCUser userQ = new WxCUser(); WxCUser userQ = new WxCUser();
userQ.updateTenantInfo(record); userQ.updateTenantInfo(record);
@@ -108,7 +96,7 @@ public class WxBusinessCircleOrderServiceImpl implements WxBusinessCircleOrderSe
if(user != null && user.getUserId() != null){ if(user != null && user.getUserId() != null){
record.setCUserId(user.getUserId()); record.setCUserId(user.getUserId());
}else{ }else{
logger.error("--商圈付款通知消息未找到会员--openid="+record.getOpenid());
logger.error("--Wx商圈付款通知消息未找到会员--openid="+record.getOpenid());
} }
wxBusinessCircleOrderMapper.insertNoticeOrder(record); wxBusinessCircleOrderMapper.insertNoticeOrder(record);


@@ -130,7 +118,7 @@ public class WxBusinessCircleOrderServiceImpl implements WxBusinessCircleOrderSe
creditHistory.setMerchantId(record.getMerchantId()); creditHistory.setMerchantId(record.getMerchantId());
creditHistory.setCreditType(EnumScoreType.CONSUMPTION.getCode()); creditHistory.setCreditType(EnumScoreType.CONSUMPTION.getCode());
creditHistory.setSpend(record.getPayAmount()); creditHistory.setSpend(record.getPayAmount());
creditHistory.setChangePurpose("商圈消费:消费商户["+record.getWxShopName()+"] ("+record.getPayAmountStr()+"元) ");
creditHistory.setChangePurpose("Wx商圈消费:消费商户["+record.getWxShopName()+"] ("+record.getPayAmountStr()+"元) ");
creditHistory = creditHistoryService.saveOrUpdate(creditHistory,record.getTenantId()); creditHistory = creditHistoryService.saveOrUpdate(creditHistory,record.getTenantId());
Integer creditNum = 0; Integer creditNum = 0;
if (creditHistory.getCreditNum() != null) { if (creditHistory.getCreditNum() != null) {
@@ -153,7 +141,7 @@ public class WxBusinessCircleOrderServiceImpl implements WxBusinessCircleOrderSe
public void insertRefundNoticeOrder(WxBusinessCircleOrder record) { public void insertRefundNoticeOrder(WxBusinessCircleOrder record) {
WxBusinessCircleOrder order = this.getOrderByTransactionId(record.getTransactionId(),record.getTenantId()); WxBusinessCircleOrder order = this.getOrderByTransactionId(record.getTransactionId(),record.getTenantId());
if(order == null){ if(order == null){
logger.error("--商圈退款--付款消息未找到--transactionId="+record.getTransactionId());
logger.error("--Wx商圈退款--付款消息未找到--transactionId="+record.getTransactionId());
}else{ }else{
List<WxBusinessCircleOrder> refundOrders = this.getRefundOrderByTransactionId(record.getTransactionId(),record.getTenantId()); List<WxBusinessCircleOrder> refundOrders = this.getRefundOrderByTransactionId(record.getTransactionId(),record.getTenantId());
Integer amount = order.getPayAmount(); Integer amount = order.getPayAmount();
@@ -168,9 +156,9 @@ public class WxBusinessCircleOrderServiceImpl implements WxBusinessCircleOrderSe
} }
} }
if(refundAmount >= amount){ if(refundAmount >= amount){
logger.error("--商圈退款--已经退款--transactionId="+record.getTransactionId());
logger.error("--Wx商圈退款--已经退款--transactionId="+record.getTransactionId());
}else if((refundAmount + record.getRefundAmount()) > amount ){ }else if((refundAmount + record.getRefundAmount()) > amount ){
logger.error("--商圈退款--退款金额超限--transactionId="+record.getTransactionId());
logger.error("--Wx商圈退款--退款金额超限--transactionId="+record.getTransactionId());
}else{ }else{
Date now = new Date(); Date now = new Date();
final IdWorker idWorker = IdWorker.get(); final IdWorker idWorker = IdWorker.get();
@@ -204,7 +192,7 @@ public class WxBusinessCircleOrderServiceImpl implements WxBusinessCircleOrderSe


creditHistory.setCreditNum(points); creditHistory.setCreditNum(points);
creditHistory.setSpend(0-record.getRefundAmount()); creditHistory.setSpend(0-record.getRefundAmount());
creditHistory.setChangePurpose("商圈消费退款:商户["+record.getWxShopName()+"] ("+record.getRefundAmountStr()+"元) ");
creditHistory.setChangePurpose("Wx商圈消费退款:商户["+record.getWxShopName()+"] ("+record.getRefundAmountStr()+"元) ");
creditHistory = creditHistoryService.saveOrUpdate(creditHistory,record.getTenantId()); creditHistory = creditHistoryService.saveOrUpdate(creditHistory,record.getTenantId());
Integer creditNum = 0; Integer creditNum = 0;
if (creditHistory.getCreditNum() != null) { if (creditHistory.getCreditNum() != null) {


+ 3
- 1
mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java Прегледај датотеку

@@ -118,7 +118,9 @@ public class WxCouponServiceImpl implements WxCouponService {
public ResultData list(TenantEntity tenantEntity,WxCoupon wxCoupon, Integer pageNum, Integer pageSize) { public ResultData list(TenantEntity tenantEntity,WxCoupon wxCoupon, Integer pageNum, Integer pageSize) {
if (null == wxCoupon) wxCoupon = new WxCoupon(); if (null == wxCoupon) wxCoupon = new WxCoupon();
wxCoupon.updateTenantInfo(tenantEntity); wxCoupon.updateTenantInfo(tenantEntity);
wxCoupon.setSortColumns(BaseEntity.SortField.CCreateDate_DESC, BaseEntity.SortField.CId_DESC);
if(StringUtils.isBlank(wxCoupon.getSortColumns())){
wxCoupon.setSortColumns(BaseEntity.SortField.CCreateDate_DESC, BaseEntity.SortField.CId_DESC);
}
PageInfo<WxCoupon> page = null; PageInfo<WxCoupon> page = null;
if (wxCoupon.getStatus() != null && wxCoupon.getStatus() == -1) if (wxCoupon.getStatus() != null && wxCoupon.getStatus() == -1)
wxCoupon.setStatus(null); wxCoupon.setStatus(null);


+ 289
- 216
mallinkService/src/main/java/com/iformall/service/impl/WxThirdPartyOrdersServiceImpl.java Прегледај датотеку

@@ -1,216 +1,289 @@
//package com.iformall.service.impl;
//
//import com.github.pagehelper.PageHelper;
//import com.github.pagehelper.PageInfo;
//import com.iformall.common.ErrorCode;
//import com.iformall.common.IdWorker;
//import com.iformall.domain.po.WxCUserBasicInfo;
//import com.iformall.domain.po.WxCreditHistory;
//import com.iformall.domain.po.WxMerchant;
//import com.iformall.domain.po.WxThirdPartyOrders;
//import com.iformall.domain.po.msg.FmInsideCircleOrderMsg;
//import com.iformall.enums.*;
//import com.iformall.exception.MallinkException;
//import com.iformall.mapper.WxThirdPartyOrdersMapper;
//import com.iformall.mq.MqBaseProducer;
//import com.iformall.service.*;
//import org.apache.commons.lang3.StringUtils;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//
//import java.util.Date;
//
//import static org.springframework.transaction.annotation.Propagation.REQUIRED;
//
//@Service
//public class WxThirdPartyOrdersServiceImpl implements WxThirdPartyOrdersService {
// private final Logger logger = LoggerFactory.getLogger(this.getClass());
//
// @Autowired
// WxThirdPartyOrdersMapper wxThirdPartyOrdersMapper;
//
// @Autowired
// WxMerchantService wxMerchantService;
//
// @Autowired
// WxCUserService wxCUserService;
//
// @Autowired
// WxCUserBasicInfoService wxCUserBasicInfoService;
//
// @Autowired
// MqBaseProducer mqBaseProducer;
//
// @Autowired
// WxCreditHistoryService wxCreditHistoryService;
//
//
// @Override
// public PageInfo<WxThirdPartyOrders> listAsPage(WxThirdPartyOrders record, Integer pageIndex, Integer pageSize) {
// return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxThirdPartyOrdersMapper.findList(record));
// }
//
// @Override
// public WxThirdPartyOrders getById(Long id, String tenantId) {
// WxThirdPartyOrders recordQ = new WxThirdPartyOrders();
// recordQ.setId(id);
// recordQ.setTenantId(tenantId);
// return wxThirdPartyOrdersMapper.getById(recordQ);
// }
//
// @Override
// public WxThirdPartyOrders getByTransactionId(String transactionId, String tenantId) {
// WxThirdPartyOrders recordQ = new WxThirdPartyOrders();
// recordQ.setTransactionId(transactionId);
// recordQ.setTenantId(tenantId);
// return wxThirdPartyOrdersMapper.getByTransactionId(recordQ);
// }
//
// @Override
// public void createOrder(WxThirdPartyOrders record) {
// WxThirdPartyOrders byTransactionId = wxThirdPartyOrdersMapper.getByTransactionId(record);
// if(byTransactionId != null){
// logger.error("--第三方付款--通知消息已存在---byTransactionId="+byTransactionId.getTransactionId());
// throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "订单数据已存在");
// }else{
// Date now = new Date();
// final IdWorker idWorker = IdWorker.get();
// record.setId(idWorker.nextId());
// record.setCreateTime(now);
// record.setUpdateTime(now);
//
// record.setSourceType(EnumThirdOrderType.RMB_PAY.getCode());
//
// //TODO 第三方获取门店(标识可能发生变化)
// WxMerchant wxMerchant = wxMerchantService.getById(Long.parseLong(record.getShopNumber()));
// if(wxMerchant != null){
// record.setMerchantId(wxMerchant.getId());
// }else{
// logger.info("--第三方付款通知消息未找到门店--shopName="+record.getShopName()+"&shopNumber="+record.getShopNumber());
// }
//
// WxCUserBasicInfo basicInfo = null;
// basicInfo = wxCUserBasicInfoService.getById(Long.parseLong(record.getUserNumber()), record.getFinalTenantId());
// if(basicInfo == null){
// basicInfo = wxCUserBasicInfoService.registerByPhone(record, record.getUserPhone());
// }
//
// if(basicInfo != null){
// record.setCUserId(basicInfo.getId());
// }else{
// logger.error("--第三方付款通知消息未找到会员--userPhone="+record.getUserPhone()+"$userNumer="+record.getId());
// }
// wxThirdPartyOrdersMapper.insertNoticeOrder(record);
//
// this.sendMessage(record,EnumYesOrNo.NO.getCode());
//
// }
// }
//
// /**
// *
// * @param record
// * @param isRefund 是否退款
// */
// private void sendMessage(WxThirdPartyOrders record,Integer isRefund){
// FmInsideCircleOrderMsg msg = new FmInsideCircleOrderMsg();
// msg.setMsgType(EnumMsgRecordType.THIRD_PARTY_NOTICE.getCode());
// msg.updateTenantInfo(record);
// msg.setIsRefund(isRefund);
// msg.setCircleOrderId(record.getId());
// msg.setMerchantId(record.getMerchantId());
// msg.setCUserId(record.getCUserId());
// msg.setShopName(record.getShopName());
// msg.setUserPhone(record.getUserPhone());
// msg.setAmount(record.getAmount());
// mqBaseProducer.sendMessage(msg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode());
// }
//
// @Override
// public void updateRefundOrder(WxThirdPartyOrders record) {
// WxThirdPartyOrders byTransactionId = this.getByTransactionId(record.getTransactionId(),record.getTenantId());
// if(byTransactionId == null){
// logger.error("--第三方退款--付款消息未找到--transactionId="+record.getTransactionId());
// throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "付款消息未找到");
// }else if(byTransactionId.getIsRefund().equals(EnumYesOrNo.YES.getCode())){
// logger.error("--第三方退款--已是退款状态--transactionId="+record.getTransactionId());
// throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "已是退款状态");
// }else{
// Date now = new Date();
// record.setId(byTransactionId.getId());
// record.setUpdateTime(now);
// wxThirdPartyOrdersMapper.updateRefundNoticeOrder(record);
//
// this.sendMessage(record,EnumYesOrNo.YES.getCode());
// }
// }
//
// @Override
// public void updateAddPoints(WxThirdPartyOrders record) {
// record.setUpdateTime(new Date());
// wxThirdPartyOrdersMapper.updateAddPoints(record);
// }
//
// @Override
// public void updateRefundPoints(WxThirdPartyOrders record) {
// record.setUpdateTime(new Date());
// wxThirdPartyOrdersMapper.updateRefundPoints(record);
// }
//
// @Transactional(propagation = REQUIRED ,rollbackFor = Exception.class)
// @Override
// public void pointDeduction(WxThirdPartyOrders record) {
//
// WxCUserBasicInfo basicInfo = null;
// if(StringUtils.isNotBlank(record.getUserNumber())){
// basicInfo = wxCUserBasicInfoService.getById(Long.parseLong(record.getUserNumber()), record.getFinalTenantId());
// }
// if(basicInfo == null){
// logger.error("--第三方积分订单--未找到用户---userId="+record.getUserNumber());
// throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "未找到用户");
// }
//
// record.setCUserId(basicInfo.getId());
//
// WxThirdPartyOrders byTransactionId = wxThirdPartyOrdersMapper.getByTransactionId(record);
// if(byTransactionId != null){
// logger.error("--第三方积分订单--数据已存在---byTransactionId="+byTransactionId.getTransactionId());
// throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "订单数据已存在");
// }else{
// Date now = new Date();
// final IdWorker idWorker = IdWorker.get();
// record.setId(idWorker.nextId());
// record.setCreateTime(now);
// record.setUpdateTime(now);
//
// record.setSourceType(EnumThirdOrderType.CREDIT_PAY.getCode());
//
// //TODO 第三方获取门店(标识可能发生变化)
// WxMerchant wxMerchant = wxMerchantService.getById(Long.parseLong(record.getShopNumber()));
// if(wxMerchant != null){
// record.setMerchantId(wxMerchant.getId());
// }else{
// logger.info("--第三方付款通知消息未找到门店--shopName="+record.getShopName()+"&shopNumber="+record.getShopNumber());
// }
//
// WxCreditHistory wxCreditHistory = new WxCreditHistory();
// wxCreditHistory.setTenantId(record.getFinalTenantId());
// wxCreditHistory.setCUserId(basicInfo.getId());
// wxCreditHistory.setOperatorId(basicInfo.getId());
// wxCreditHistory.setOperatorType(EnumUserType.THIRD_CIRCLE.getCode());
// wxCreditHistory.setCreditNum(record.getAmount());
// wxCreditHistory.setCreditType(EnumScoreType.CHANGE_CREDIT.getCode());
// wxCreditHistory.setChangePurpose("第三方消费抵扣{}"+record.getSummary());
// wxCreditHistory.setCouponId(record.getId());
// wxCreditHistoryService.saveOrUpdate(wxCreditHistory,record.getTenantId());
//
// wxThirdPartyOrdersMapper.insertNoticeOrder(record);
// }
//
// }
//
//
//}
package com.iformall.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.iformall.common.ErrorCode;
import com.iformall.common.IdWorker;
import com.iformall.domain.po.*;
import com.iformall.enums.*;
import com.iformall.exception.MallinkException;
import com.iformall.mapper.WxThirdPartyOrdersMapper;
import com.iformall.service.*;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

import static org.springframework.transaction.annotation.Propagation.REQUIRED;

@Service
public class WxThirdPartyOrdersServiceImpl implements WxThirdPartyOrdersService {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
WxThirdPartyOrdersMapper wxThirdPartyOrdersMapper;

@Autowired
WxMerchantService wxMerchantService;

@Autowired
WxCUserService wxCUserService;

@Autowired
WxCUserBasicInfoService wxCUserBasicInfoService;

@Autowired
WxCreditHistoryService wxCreditHistoryService;



@Override
public PageInfo<WxThirdPartyOrders> listAsPage(WxThirdPartyOrders record, Integer pageIndex, Integer pageSize) {
return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxThirdPartyOrdersMapper.findList(record));
}

@Override
public WxThirdPartyOrders getById(Long id, String tenantId) {
WxThirdPartyOrders recordQ = new WxThirdPartyOrders();
recordQ.setId(id);
recordQ.setTenantId(tenantId);
return wxThirdPartyOrdersMapper.getById(recordQ);
}

@Override
public WxThirdPartyOrders getOrderByTransactionId(EnumThirdOrderType orderType, String transactionId, String tenantId) {
WxThirdPartyOrders recordQ = new WxThirdPartyOrders();
recordQ.setSourceType(orderType.getCode());
recordQ.setTransactionId(transactionId);
recordQ.setTenantId(tenantId);
return wxThirdPartyOrdersMapper.getOrderByTransactionId(recordQ);
}

@Override
public List<WxThirdPartyOrders> getRefundOrderByTransactionId(EnumThirdOrderType orderType, String transactionId, String tenantId) {
WxThirdPartyOrders recordQ = new WxThirdPartyOrders();
recordQ.setSourceType(orderType.getCode());
recordQ.setTransactionId(transactionId);
recordQ.setTenantId(tenantId);
return wxThirdPartyOrdersMapper.getRefundOrderByTransactionId(recordQ);
}

@Override
public void createOrder(WxThirdPartyOrders record) {
WxThirdPartyOrders byTransactionId = this.getOrderByTransactionId(EnumThirdOrderType.RMB_PAY,record.getTransactionId(),record.getTenantId());
if(byTransactionId != null){
logger.error("--第三方付款--通知消息已存在---byTransactionId="+byTransactionId.getTransactionId());
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "订单数据已存在");
}else{
Date now = new Date();
final IdWorker idWorker = IdWorker.get();
record.setId(idWorker.nextId());
record.setCreateTime(now);
record.setUpdateTime(now);

record.setSourceType(EnumThirdOrderType.RMB_PAY.getCode());

//TODO 第三方获取门店(标识可能发生变化)
WxMerchant wxMerchant = wxMerchantService.getById(Long.parseLong(record.getShopNumber()));
if(wxMerchant != null){
record.setMerchantId(wxMerchant.getId());
}else{
logger.info("--第三方付款通知消息未找到门店--shopName="+record.getShopName()+"&shopNumber="+record.getShopNumber());
}

WxCUserBasicInfo basicInfo = null;
basicInfo = wxCUserBasicInfoService.getById(Long.parseLong(record.getUserNumber()), record.getFinalTenantId());
if(basicInfo == null){
basicInfo = wxCUserBasicInfoService.registerByPhone(record, record.getUserPhone());
}

if(basicInfo != null){
record.setCUserId(basicInfo.getId());
}else{
logger.error("--第三方付款通知消息未找到会员--userPhone="+record.getUserPhone()+"$userNumer="+record.getId());
}
wxThirdPartyOrdersMapper.insertNoticeOrder(record);

if(record.getCUserId() == null){
return;
}
Integer businessId = EnumBusiness.BUSINESS_ID6.getCode();
if(wxMerchant != null){
businessId = wxMerchant.getBusinessId();
}
WxCreditHistory creditHistory = new WxCreditHistory();
creditHistory.setTenantId(record.getFinalTenantId());
creditHistory.setOperatorType(EnumUserType.THIRD_CIRCLE.getCode());
creditHistory.setOperatorId(record.getCUserId());
creditHistory.setCUserId(record.getCUserId());
creditHistory.setCreateDate(now);
creditHistory.setCouponId(record.getId());
creditHistory.setBusinessId(businessId);
creditHistory.setMerchantId(record.getMerchantId());
creditHistory.setCreditType(EnumScoreType.CONSUMPTION.getCode());
creditHistory.setSpend(record.getPayAmount());
creditHistory.setChangePurpose("第三方消费:消费商户["+record.getShopName()+"] ("+record.getPayAmountStr()+"元) ");
creditHistory = wxCreditHistoryService.saveOrUpdate(creditHistory,record.getTenantId());
Integer creditNum = 0;
if (creditHistory.getCreditNum() != null) {
creditNum = creditHistory.getCreditNum();
}
if(creditNum == 0){
return;
}
record.setIncreasedPoints(creditNum);
record.setPointsUpdateTime(creditHistory.getCreateDate());
this.updatePoints(record);


}
}


@Override
public void insertRefundNoticeOrder(WxThirdPartyOrders record) {
WxThirdPartyOrders order = this.getOrderByTransactionId(EnumThirdOrderType.RMB_PAY,record.getTransactionId(),record.getTenantId());
if(order == null){
logger.error("--第三方退款--付款消息未找到--transactionId="+record.getTransactionId());
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "付款消息未找到");
}else if(order.getIsRefund().equals(EnumYesOrNo.YES.getCode())){
logger.error("--第三方退款--已是退款状态--transactionId="+record.getTransactionId());
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "已是退款状态");
}else{
List<WxThirdPartyOrders> refundOrders = this.getRefundOrderByTransactionId(EnumThirdOrderType.RMB_PAY,record.getTransactionId(),record.getTenantId());
Integer amount = order.getPayAmount();
Integer increasedPoints = order.getIncreasedPoints();
Integer refundAmount = 0;
Integer refundIncreasedPoints = 0;

if(refundOrders != null && refundOrders.size()>0){
for (WxThirdPartyOrders ro:refundOrders) {
refundAmount += ro.getRefundAmount();
refundIncreasedPoints += ro.getIncreasedPoints();
}
}
if(refundAmount >= amount){
logger.error("--第三方退款--已经退款--transactionId="+record.getTransactionId());
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "已经退款");
}else if((refundAmount + record.getRefundAmount()) > amount ){
logger.error("--第三方退款--退款金额超限--transactionId="+record.getTransactionId());
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "退款金额超限");
}else{

Date now = new Date();
final IdWorker idWorker = IdWorker.get();
record.setId(idWorker.nextId());
record.setCreateTime(now);
record.setUpdateTime(now);

record.setCUserId(order.getCUserId());
record.setMerchantId(order.getMerchantId());
wxThirdPartyOrdersMapper.insertRefundNoticeOrder(record);

if(order.getEarnPoints().equals(EnumYesOrNo.YES.getCode())){
WxCreditHistory creditHistory = new WxCreditHistory();
creditHistory.setTenantId(record.getFinalTenantId());
creditHistory.setOperatorType(EnumUserType.THIRD_CIRCLE.getCode());
creditHistory.setOperatorId(record.getCUserId());
creditHistory.setCUserId(record.getCUserId());
creditHistory.setCreateDate(new Date());
creditHistory.setCouponId(record.getId());
creditHistory.setMerchantId(record.getMerchantId());
creditHistory.setCreditType(EnumScoreType.REFUND_CONSUMPTION.getCode());
int points = 0;
if((refundAmount + record.getRefundAmount()) == amount){
points = increasedPoints - refundIncreasedPoints;
}else{
points = new BigDecimal(order.getIncreasedPoints())
.divide(new BigDecimal(order.getPayAmount()),2,BigDecimal.ROUND_HALF_UP)
.multiply(new BigDecimal(record.getRefundAmount()))
.intValue();
}

creditHistory.setCreditNum(points);
creditHistory.setSpend(0-record.getRefundAmount());
creditHistory.setChangePurpose("第三方消费退款:商户["+record.getShopName()+"] ("+record.getRefundAmountStr()+"元) ");
creditHistory = wxCreditHistoryService.saveOrUpdate(creditHistory,record.getTenantId());
Integer creditNum = 0;
if (creditHistory.getCreditNum() != null) {
creditNum = creditHistory.getCreditNum();
}
if(creditNum == 0){
return;
}

record.setIncreasedPoints(creditNum);
record.setPointsUpdateTime(creditHistory.getCreateDate());
this.updatePoints(record);
}
}

}
}

@Override
public void updatePoints(WxThirdPartyOrders record) {
record.setUpdateTime(new Date());
wxThirdPartyOrdersMapper.updatePoints(record);
}

@Transactional(propagation = REQUIRED ,rollbackFor = Exception.class)
@Override
public void pointDeduction(WxThirdPartyOrders record) {

WxCUserBasicInfo basicInfo = null;
if(StringUtils.isNotBlank(record.getUserNumber())){
basicInfo = wxCUserBasicInfoService.getById(Long.parseLong(record.getUserNumber()), record.getFinalTenantId());
}
if(basicInfo == null){
logger.error("--第三方积分订单--未找到用户---userId="+record.getUserNumber());
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "未找到用户");
}

record.setCUserId(basicInfo.getId());

WxThirdPartyOrders byTransactionId = this.getOrderByTransactionId(EnumThirdOrderType.CREDIT_PAY,record.getTransactionId(),record.getTenantId());
if(byTransactionId != null){
logger.error("--第三方积分订单--数据已存在---byTransactionId="+byTransactionId.getTransactionId());
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "订单数据已存在");
}else{
Date now = new Date();
final IdWorker idWorker = IdWorker.get();
record.setId(idWorker.nextId());
record.setCreateTime(now);
record.setUpdateTime(now);

record.setSourceType(EnumThirdOrderType.CREDIT_PAY.getCode());

//TODO 第三方获取门店(标识可能发生变化)
WxMerchant wxMerchant = wxMerchantService.getById(Long.parseLong(record.getShopNumber()));
if(wxMerchant != null){
record.setMerchantId(wxMerchant.getId());
}else{
logger.info("--第三方付款通知消息未找到门店--shopName="+record.getShopName()+"&shopNumber="+record.getShopNumber());
}

WxCreditHistory wxCreditHistory = new WxCreditHistory();
wxCreditHistory.setTenantId(record.getFinalTenantId());
wxCreditHistory.setCUserId(basicInfo.getId());
wxCreditHistory.setOperatorId(basicInfo.getId());
wxCreditHistory.setOperatorType(EnumUserType.THIRD_CIRCLE.getCode());
wxCreditHistory.setCreditNum(record.getAmount());
wxCreditHistory.setCreditType(EnumScoreType.CHANGE_CREDIT.getCode());
wxCreditHistory.setChangePurpose("第三方消费抵扣{}"+record.getSummary());
wxCreditHistory.setCouponId(record.getId());
wxCreditHistoryService.saveOrUpdate(wxCreditHistory,record.getTenantId());

wxThirdPartyOrdersMapper.insertNoticeOrder(record);
}

}


}

+ 203
- 0
mallinkService/src/main/resources/mapper/AliBusinessCircleMapper.xml Прегледај датотеку

@@ -0,0 +1,203 @@
<?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.WxThirdPartyOrdersMapper">
<resultMap id="BaseResultMap" type="com.iformall.domain.po.WxThirdPartyOrders">
<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_app_id" jdbcType="VARCHAR" property="sourceAppId"/>
<result column="source_type" jdbcType="INTEGER" 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="shop_name" jdbcType="VARCHAR" property="shopName" />
<result column="shop_number" jdbcType="VARCHAR" property="shopNumber" />
<result column="user_phone" jdbcType="VARCHAR" property="userPhone" />
<result column="user_number" jdbcType="VARCHAR" property="userNumber" />


<result column="time_end" jdbcType="TIMESTAMP" property="timeEnd"/>
<result column="amount" jdbcType="INTEGER" property="amount"/>
<result column="pay_amount" jdbcType="INTEGER" property="payAmount"/>
<result column="transaction_id" jdbcType="VARCHAR" property="transactionId" />

<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_refund" jdbcType="TINYINT" property="isRefund"/>
<result column="refund_id" jdbcType="VARCHAR" property="refundId" />
<result column="refund_amount" jdbcType="INTEGER" property="refundAmount"/>

</resultMap>


<sql id="allColumns">
`id`, `tenant_id`, `parent_tenant_id`, `source_app_id`, `source_type`,`notice_id`, `notice_create_time`, `notice_event_type`,
`notice_resource_type`, `summary`,`shop_name`, `shop_number`, `user_phone`, `user_number`,
`time_end`, `amount`, `pay_amount`, `transaction_id`, `create_time`, `update_time`,
`merchant_id`, `c_user_id`, `earn_points`, `increased_points`, `points_update_time`,
`is_refund`, `refund_id`, `refund_amount`
</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 != sourceAppId and '' != sourceAppId">
and `source_app_id` = #{sourceAppId}
</if>

<if test=" null != sourceType and '' != sourceType">
and `source_type` = #{sourceType}
</if>

<if test=" null != shopName ">
and `shop_name` like concat('%', #{shopName},'%')
</if>

<if test=" null != shopNumber and '' != shopNumber">
and `shop_number` = #{shopNumber}
</if>

<if test=" null != userPhone and '' != userPhone">
and `user_phone` = #{userPhone}
</if>

<if test=" null != userNumber and '' != userNumber">
and `user_number` = #{userNumber}
</if>

<if test=" null != noticeId and '' != noticeId">
and `notice_id` = #{noticeId}
</if>

<if test=" null != startTime ">
and `time_end` &gt;= #{startTime}
</if>
<if test=" null != endTime">
and `time_end` &lt; #{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 != isRefund ">
and `is_refund` = #{isRefund}
</if>

<if test=" null != refundId and '' != refundId">
and `refund_id` = #{refundId}
</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.WxThirdPartyOrders" resultMap="BaseResultMap">
select
<include refid="allColumns"/>
from wx_third_party_orders
<include refid="dynamicWhereConditions"/>
</select>

<select id="getById" parameterType="com.iformall.domain.po.WxThirdPartyOrders" resultMap="BaseResultMap">
select
<include refid="allColumns"/>
from wx_third_party_orders
where `id` = #{id}
and tenant_id=#{tenantId}
</select>

<select id="getOrderByTransactionId" parameterType="com.iformall.domain.po.WxThirdPartyOrders" resultMap="BaseResultMap">
select
<include refid="allColumns"/>
from wx_third_party_orders
where `is_refund` = 0
and tenant_id = #{tenantId}
and `transaction_id` = #{transactionId}
</select>

<select id="getRefundOrderByTransactionId" parameterType="com.iformall.domain.po.WxThirdPartyOrders" resultMap="BaseResultMap">
select
<include refid="allColumns"/>
from wx_third_party_orders
where `is_refund` = 1
and tenant_id = #{tenantId}
and `transaction_id` = #{transactionId}
</select>

<insert id="insertNoticeOrder" parameterType="com.iformall.domain.po.WxThirdPartyOrders" >
INSERT INTO wx_third_party_orders (
`id`, `tenant_id`, `parent_tenant_id`,`source_app_id`, `source_type`, `notice_id`, `notice_create_time`, `notice_event_type`,
`notice_resource_type`, `summary`, `shop_name`, `shop_number`, `user_phone`, `user_number`,`time_end`, `amount`, `pay_amount`, `transaction_id`, `commit_tag`, `create_time`, `update_time`,
`merchant_id`, `c_user_id`, `earn_points`, `is_refund`
)
VALUES(
#{id},#{tenantId},#{parentTenantId},#{sourceAppId},#{sourceType},#{noticeId},#{noticeCreateTime},#{noticeEventType},
#{noticeResourceType},#{summary},#{shopName},#{shopNumber},#{userPhone},#{userNumber},#{timeEnd},#{amount},#{payAmount},#{transactionId},#{commitTag},#{createTime},#{updateTime},
#{merchantId},#{cUserId},0,0
);
</insert>

<update id="updatePoints" parameterType="com.iformall.domain.po.WxThirdPartyOrders">
update wx_third_party_orders set
`earn_points` = 1, `increased_points` = #{increasedPoints}, `points_update_time` = #{pointsUpdateTime},
`is_refund_points` = 0, `update_time` = #{updateTime}
where `id` = #{id} and `tenant_id` = #{tenantId}
</update>

<insert id="insertRefundNoticeOrder" parameterType="com.iformall.domain.po.WxThirdPartyOrders" >
INSERT INTO wx_third_party_orders (
`id`, `tenant_id`, `parent_tenant_id`,`source_app_id`, `source_type`, `notice_id`, `notice_create_time`, `notice_event_type`,
`notice_resource_type`, `summary`,`shop_name`, `shop_number`, `user_phone`, `user_number`, `time_end`, `amount`,`pay_amount`, `transaction_id`, `commit_tag`, `create_time`, `update_time`,
`merchant_id`, `c_user_id`, `earn_points`, `is_refund`, `refund_id`, `refund_amount`
)
VALUES(
#{id},#{tenantId},#{parentTenantId},#{sourceAppId},#{sourceType},#{noticeId},#{noticeCreateTime},#{noticeEventType},
#{noticeResourceType},#{summary},#{shopName},#{shopNumber},#{userPhone},#{userNumber},#{timeEnd},#{amount},#{payAmount},#{transactionId},#{commitTag},#{createTime},#{updateTime},
#{merchantId},#{cUserId},0,1,#{refundId},#{refundAmount}
);
</insert>

</mapper>

+ 183
- 0
mallinkService/src/main/resources/mapper/AliBusinessCircleOrder.xml Прегледај датотеку

@@ -0,0 +1,183 @@
<?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.AliBusinessCircleOrderMapper">
<resultMap id="BaseResultMap" type="com.iformall.domain.po.AliBusinessCircleOrder">
<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="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="mall_id" jdbcType="VARCHAR" property="mallId" />
<result column="mall_name" jdbcType="VARCHAR" property="mallName" />
<result column="mall_store_id" jdbcType="VARCHAR" property="mallStoreId" />
<result column="buyer_id" jdbcType="VARCHAR" property="buyerId" />

<result column="time_end" jdbcType="TIMESTAMP" property="timeEnd"/>
<result column="amount" jdbcType="INTEGER" property="amount"/>
<result column="pay_amount" jdbcType="INTEGER" property="payAmount"/>
<result column="transaction_id" jdbcType="VARCHAR" property="transactionId" />

<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_refund" jdbcType="TINYINT" property="isRefund"/>
<result column="refund_id" jdbcType="VARCHAR" property="refundId" />
<result column="refund_amount" jdbcType="INTEGER" property="refundAmount"/>

</resultMap>


<sql id="allColumns">
`id`, `tenant_id`, `parent_tenant_id`, `notice_id`, `notice_create_time`, `notice_event_type`,
`notice_resource_type`, `summary`,`mall_id`, `mall_name`, `mall_store_id`, `buyer_id`,
`time_end`, `amount`, `pay_amount`, `transaction_id`, `create_time`, `update_time`,
`merchant_id`, `c_user_id`, `earn_points`, `increased_points`, `points_update_time`,
`is_refund`, `refund_id`, `refund_amount`
</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 != mallStoreId and '' != mallStoreId">
and `mall_store_id` = #{mallStoreId}
</if>

<if test=" null != buyerId and '' != buyerId">
and `buyer_id` = #{buyerId}
</if>

<if test=" null != noticeId and '' != noticeId">
and `notice_id` = #{noticeId}
</if>

<if test=" null != startTime ">
and `time_end` &gt;= #{startTime}
</if>
<if test=" null != endTime">
and `time_end` &lt; #{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 != isRefund ">
and `is_refund` = #{isRefund}
</if>

<if test=" null != refundId and '' != refundId">
and `refund_id` = #{refundId}
</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.WxThirdPartyOrders" resultMap="BaseResultMap">
select
<include refid="allColumns"/>
from ali_business_circle_order
<include refid="dynamicWhereConditions"/>
</select>

<select id="getById" parameterType="com.iformall.domain.po.WxThirdPartyOrders" resultMap="BaseResultMap">
select
<include refid="allColumns"/>
from ali_business_circle_order
where `id` = #{id}
and tenant_id=#{tenantId}
</select>

<select id="getOrderByTransactionId" parameterType="com.iformall.domain.po.WxThirdPartyOrders" resultMap="BaseResultMap">
select
<include refid="allColumns"/>
from ali_business_circle_order
where `is_refund` = 0
and tenant_id = #{tenantId}
and `transaction_id` = #{transactionId}
</select>

<select id="getRefundOrderByTransactionId" parameterType="com.iformall.domain.po.WxThirdPartyOrders" resultMap="BaseResultMap">
select
<include refid="allColumns"/>
from ali_business_circle_order
where `is_refund` = 1
and tenant_id = #{tenantId}
and `transaction_id` = #{transactionId}
</select>

<insert id="insertNoticeOrder" parameterType="com.iformall.domain.po.WxThirdPartyOrders" >
INSERT INTO ali_business_circle_order (
`id`, `tenant_id`, `parent_tenant_id`, `notice_id`, `notice_create_time`, `notice_event_type`,
`notice_resource_type`, `summary`, `mall_id`, `mall_name`, `mall_store_id`, `buyer_id`,`time_end`, `amount`, `pay_amount`, `transaction_id`, `commit_tag`, `create_time`, `update_time`,
`merchant_id`, `c_user_id`, `earn_points`, `is_refund`
)
VALUES(
#{id},#{tenantId},#{parentTenantId},#{noticeId},#{noticeCreateTime},#{noticeEventType},
#{noticeResourceType},#{summary},#{mallId},#{mallName},#{mallStoreId},#{buyerId},#{timeEnd},#{amount},#{payAmount},#{transactionId},#{commitTag},#{createTime},#{updateTime},
#{merchantId},#{cUserId},0,0
);
</insert>

<update id="updatePoints" parameterType="com.iformall.domain.po.WxThirdPartyOrders">
update ali_business_circle_order set
`earn_points` = 1, `increased_points` = #{increasedPoints}, `points_update_time` = #{pointsUpdateTime},
`is_refund_points` = 0, `update_time` = #{updateTime}
where `id` = #{id} and `tenant_id` = #{tenantId}
</update>

<insert id="insertRefundNoticeOrder" parameterType="com.iformall.domain.po.WxThirdPartyOrders" >
INSERT INTO ali_business_circle_order (
`id`, `tenant_id`, `parent_tenant_id`,`notice_id`, `notice_create_time`, `notice_event_type`,
`notice_resource_type`, `summary`,`mall_id`, `mall_name`, `mall_store_id`, `buyer_id`, `time_end`, `amount`,`pay_amount`, `transaction_id`, `commit_tag`, `create_time`, `update_time`,
`merchant_id`, `c_user_id`, `earn_points`, `is_refund`, `refund_id`, `refund_amount`
)
VALUES(
#{id},#{tenantId},#{parentTenantId},#{noticeId},#{noticeCreateTime},#{noticeEventType},
#{noticeResourceType},#{summary},#{mallId},#{mallName},#{mallStoreId},#{buyerId},#{timeEnd},#{amount},#{payAmount},#{transactionId},#{commitTag},#{createTime},#{updateTime},
#{merchantId},#{cUserId},0,1,#{refundId},#{refundAmount}
);
</insert>

</mapper>

+ 58
- 42
mallinkService/src/main/resources/mapper/WxThirdPartyOrdersMapper.xml Прегледај датотеку

@@ -5,20 +5,30 @@
<id column="id" jdbcType="BIGINT" property="id"/> <id column="id" jdbcType="BIGINT" property="id"/>
<result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
<result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" /> <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />

<result column="source_app_id" jdbcType="VARCHAR" property="sourceAppId"/> <result column="source_app_id" jdbcType="VARCHAR" property="sourceAppId"/>
<result column="source_type" jdbcType="INTEGER" property="sourceType"/> <result column="source_type" jdbcType="INTEGER" 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="shop_name" jdbcType="VARCHAR" property="shopName" /> <result column="shop_name" jdbcType="VARCHAR" property="shopName" />
<result column="shop_number" jdbcType="VARCHAR" property="shopNumber" /> <result column="shop_number" jdbcType="VARCHAR" property="shopNumber" />
<result column="user_phone" jdbcType="VARCHAR" property="userPhone" /> <result column="user_phone" jdbcType="VARCHAR" property="userPhone" />
<result column="user_number" jdbcType="VARCHAR" property="userNumber" /> <result column="user_number" jdbcType="VARCHAR" property="userNumber" />


<result column="time_end" jdbcType="TIMESTAMP" property="timeEnd"/> <result column="time_end" jdbcType="TIMESTAMP" property="timeEnd"/>
<result column="amount" jdbcType="INTEGER" property="amount"/> <result column="amount" jdbcType="INTEGER" property="amount"/>
<result column="pay_amount" jdbcType="INTEGER" property="payAmount"/>
<result column="transaction_id" jdbcType="VARCHAR" property="transactionId" /> <result column="transaction_id" jdbcType="VARCHAR" property="transactionId" />
<result column="summary" jdbcType="VARCHAR" property="summary" />


<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/> <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/> <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>

<result column="merchant_id" jdbcType="BIGINT" property="merchantId"/> <result column="merchant_id" jdbcType="BIGINT" property="merchantId"/>
<result column="c_user_id" jdbcType="BIGINT" property="cUserId"/> <result column="c_user_id" jdbcType="BIGINT" property="cUserId"/>


@@ -26,25 +36,20 @@
<result column="increased_points" jdbcType="INTEGER" property="increasedPoints"/> <result column="increased_points" jdbcType="INTEGER" property="increasedPoints"/>
<result column="points_update_time" jdbcType="TIMESTAMP" property="pointsUpdateTime"/> <result column="points_update_time" jdbcType="TIMESTAMP" property="pointsUpdateTime"/>



<result column="is_refund" jdbcType="TINYINT" property="isRefund"/> <result column="is_refund" jdbcType="TINYINT" property="isRefund"/>
<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="refund_id" jdbcType="VARCHAR" property="refundId" />

<result column="is_refund_points" jdbcType="TINYINT" property="isRefundPoints"/>
<result column="refund_points_time" jdbcType="TIMESTAMP" property="refundPointsTime"/>
<result column="refund_amount" jdbcType="INTEGER" property="refundAmount"/>


</resultMap> </resultMap>




<sql id="allColumns"> <sql id="allColumns">
`id`, `tenant_id`, `parent_tenant_id`, `source_app_id`, `source_type`, `shop_name`, `shop_number`,
`user_phone`, `user_number`, `time_end`, `amount`, `transaction_id`, `summary`,
`create_time`, `update_time`, `merchant_id`, `c_user_id`,
`earn_points`, `increased_points`, `points_update_time`,
`is_refund`, `refund_summary`, `refund_time`, `refund_amount`, `refund_id`,
`is_refund_points`, `refund_points_time`
`id`, `tenant_id`, `parent_tenant_id`, `source_app_id`, `source_type`,`notice_id`, `notice_create_time`, `notice_event_type`,
`notice_resource_type`, `summary`,`shop_name`, `shop_number`, `user_phone`, `user_number`,
`time_end`, `amount`, `pay_amount`, `transaction_id`, `create_time`, `update_time`,
`merchant_id`, `c_user_id`, `earn_points`, `increased_points`, `points_update_time`,
`is_refund`, `refund_id`, `refund_amount`
</sql> </sql>


<sql id="dynamicWhereConditions"> <sql id="dynamicWhereConditions">
@@ -85,6 +90,10 @@
and `user_number` = #{userNumber} and `user_number` = #{userNumber}
</if> </if>


<if test=" null != noticeId and '' != noticeId">
and `notice_id` = #{noticeId}
</if>

<if test=" null != startTime "> <if test=" null != startTime ">
and `time_end` &gt;= #{startTime} and `time_end` &gt;= #{startTime}
</if> </if>
@@ -116,10 +125,6 @@
and `refund_id` = #{refundId} and `refund_id` = #{refundId}
</if> </if>


<if test=" null != isRefundPoints">
and `is_refund_points` = #{isRefundPoints}
</if>

<if test=" null != ids "> <if test=" null != ids ">
and `id` in and `id` in
<foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
@@ -144,46 +149,57 @@
and tenant_id=#{tenantId} and tenant_id=#{tenantId}
</select> </select>


<select id="getByTransactionId" parameterType="com.iformall.domain.po.WxThirdPartyOrders" resultMap="BaseResultMap">
<select id="getOrderByTransactionId" parameterType="com.iformall.domain.po.WxThirdPartyOrders" resultMap="BaseResultMap">
select select
<include refid="allColumns"/> <include refid="allColumns"/>
from wx_third_party_orders from wx_third_party_orders
where `transaction_id` = #{transactionId}
and tenant_id=#{tenantId}
where `is_refund` = 0
and `sourceType` = #{sourceType}
and `tenant_id` = #{tenantId}
and `transaction_id` = #{transactionId}
</select>

<select id="getRefundOrderByTransactionId" parameterType="com.iformall.domain.po.WxThirdPartyOrders" resultMap="BaseResultMap">
select
<include refid="allColumns"/>
from wx_third_party_orders
where `is_refund` = 1
and `sourceType` = #{sourceType}
and `tenant_id` = #{tenantId}
and `transaction_id` = #{transactionId}
</select> </select>


<insert id="insertNoticeOrder" parameterType="com.iformall.domain.po.WxThirdPartyOrders" > <insert id="insertNoticeOrder" parameterType="com.iformall.domain.po.WxThirdPartyOrders" >
INSERT INTO wx_business_circle_order (
`id`, `tenant_id`, `parent_tenant_id`, `source_app_id`,`source_type`,`shop_name`, `shop_number`,
`user_phone`, `user_number`, `time_end`, `amount`, `transaction_id`, `summary`,
`create_time`, `update_time`, `merchant_id`, `c_user_id`, `earn_points`, `is_refund`
INSERT INTO wx_third_party_orders (
`id`, `tenant_id`, `parent_tenant_id`,`source_app_id`, `source_type`, `notice_id`, `notice_create_time`, `notice_event_type`,
`notice_resource_type`, `summary`, `shop_name`, `shop_number`, `user_phone`, `user_number`,`time_end`, `amount`, `pay_amount`, `transaction_id`, `commit_tag`, `create_time`, `update_time`,
`merchant_id`, `c_user_id`, `earn_points`, `is_refund`
) )
VALUES( VALUES(
#{id},#{tenantId},#{parentTenantId},#{sourceAppId},#{sourceType},#{shopName},#{shopNumber},
#{userPhone},#{userNumber},#{timeEnd},#{amount},#{transactionId},#{summary},
#{createTime},#{updateTime}, #{merchantId},#{cUserId},0,0
#{id},#{tenantId},#{parentTenantId},#{sourceAppId},#{sourceType},#{noticeId},#{noticeCreateTime},#{noticeEventType},
#{noticeResourceType},#{summary},#{shopName},#{shopNumber},#{userPhone},#{userNumber},#{timeEnd},#{amount},#{payAmount},#{transactionId},#{commitTag},#{createTime},#{updateTime},
#{merchantId},#{cUserId},0,0
); );
</insert> </insert>


<update id="updateAddPoints" parameterType="com.iformall.domain.po.WxThirdPartyOrders">
update wx_business_circle_order set
<update id="updatePoints" parameterType="com.iformall.domain.po.WxThirdPartyOrders">
update wx_third_party_orders set
`earn_points` = 1, `increased_points` = #{increasedPoints}, `points_update_time` = #{pointsUpdateTime}, `earn_points` = 1, `increased_points` = #{increasedPoints}, `points_update_time` = #{pointsUpdateTime},
`is_refund_points` = 0, `update_time` = #{updateTime} `is_refund_points` = 0, `update_time` = #{updateTime}
where `id` = #{id} and `tenant_id` = #{tenantId} where `id` = #{id} and `tenant_id` = #{tenantId}
</update> </update>


<update id="updateRefundNoticeOrder" parameterType="com.iformall.domain.po.WxThirdPartyOrders">
update wx_business_circle_order set
`is_refund` = 1, `refund_summary` = #{refundSummary},
`refund_time` = #{refundTime}, `refund_amount` = #{refundAmount}, `refund_id` = #{refundId},
`update_time` = #{updateTime}
where `id` = #{id} and `tenant_id` = #{tenantId}
</update>

<update id="updateRefundPoints" parameterType="com.iformall.domain.po.WxThirdPartyOrders">
update wx_business_circle_order set
`is_refund_points` = 1, `refund_points_time` = #{refundPointsTime}, `update_time` = #{updateTime}
where `id` = #{id} and `tenant_id` = #{tenantId}
</update>
<insert id="insertRefundNoticeOrder" parameterType="com.iformall.domain.po.WxThirdPartyOrders" >
INSERT INTO wx_third_party_orders (
`id`, `tenant_id`, `parent_tenant_id`,`source_app_id`, `source_type`, `notice_id`, `notice_create_time`, `notice_event_type`,
`notice_resource_type`, `summary`,`shop_name`, `shop_number`, `user_phone`, `user_number`, `time_end`, `amount`,`pay_amount`, `transaction_id`, `commit_tag`, `create_time`, `update_time`,
`merchant_id`, `c_user_id`, `earn_points`, `is_refund`, `refund_id`, `refund_amount`
)
VALUES(
#{id},#{tenantId},#{parentTenantId},#{sourceAppId},#{sourceType},#{noticeId},#{noticeCreateTime},#{noticeEventType},
#{noticeResourceType},#{summary},#{shopName},#{shopNumber},#{userPhone},#{userNumber},#{timeEnd},#{amount},#{payAmount},#{transactionId},#{commitTag},#{createTime},#{updateTime},
#{merchantId},#{cUserId},0,1,#{refundId},#{refundAmount}
);
</insert>


</mapper> </mapper>

Loading…
Откажи
Сачувај