Browse Source

pingbierrorcode

release_toaliyun_real
xhxu 5 years ago
parent
commit
36ebe91ee1
2 changed files with 445 additions and 445 deletions
  1. +229
    -229
      mallinkPublicApi/src/main/java/com/iformall/controller/UserThirdCircleOrderController.java
  2. +216
    -216
      mallinkService/src/main/java/com/iformall/service/impl/WxThirdPartyOrdersServiceImpl.java

+ 229
- 229
mallinkPublicApi/src/main/java/com/iformall/controller/UserThirdCircleOrderController.java View File

@@ -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.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);
// }
// }
//
//}

+ 216
- 216
mallinkService/src/main/java/com/iformall/service/impl/WxThirdPartyOrdersServiceImpl.java View File

@@ -1,216 +1,216 @@
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.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);
// }
//
// }
//
//
//}

Loading…
Cancel
Save