Просмотр исходного кода

Merge branch 'release_real_202103' of https://git.malls.iformall.com/server/formallProject into release_real_202103

release_toaliyun_real
xiaohanzi 5 лет назад
Родитель
Сommit
278cd964b5
30 измененных файлов: 1491 добавлений и 2409 удалений
  1. +3
    -2
      mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponChannelController.java
  2. +6
    -2
      mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java
  3. +6
    -2
      mallinkAdmin/src/main/java/com/iformall/controller/mem/MemCouponController.java
  4. +501
    -1201
      mallinkAdmin/src/main/resources/db/migration/V202104190001__wx_business_circle_order.sql
  5. +3
    -2
      mallinkBApi/src/main/java/com/iformall/controller/WxCouponChannelController.java
  6. +6
    -2
      mallinkBApi/src/main/java/com/iformall/controller/WxCouponController.java
  7. +3
    -3
      mallinkCApi/src/main/java/com/iformall/controller/WxCouponChannelController.java
  8. +12
    -15
      mallinkCallback/src/main/java/com/iformall/controller/callback/WxBusinessOrderController.java
  9. +1
    -16
      mallinkMQConsumer/src/main/java/com/iformall/mq/MqBaseConsumer.java
  10. +0
    -40
      mallinkPublicApi/src/main/java/com/iformall/controller/UserBasicInfoController.java
  11. +229
    -229
      mallinkPublicApi/src/main/java/com/iformall/controller/UserThirdCircleOrderController.java
  12. +73
    -0
      mallinkPublicApi/src/main/java/com/iformall/utils/AppTest.java
  13. +26
    -0
      mallinkService/src/main/java/com/iformall/domain/po/AliBusinessCircleOrder.java
  14. +138
    -0
      mallinkService/src/main/java/com/iformall/domain/po/BusinessCircleBase.java
  15. +1
    -116
      mallinkService/src/main/java/com/iformall/domain/po/WxBusinessCircleOrder.java
  16. +1
    -83
      mallinkService/src/main/java/com/iformall/domain/po/WxThirdPartyOrders.java
  17. +6
    -0
      mallinkService/src/main/java/com/iformall/domain/po/base/BaseEntity.java
  18. +0
    -7
      mallinkService/src/main/java/com/iformall/domain/po/base/BaseTenantEntity.java
  19. +0
    -35
      mallinkService/src/main/java/com/iformall/domain/po/msg/FmInsideCircleOrderMsg.java
  20. +0
    -2
      mallinkService/src/main/java/com/iformall/enums/EnumMsgRecordType.java
  21. +2
    -1
      mallinkService/src/main/java/com/iformall/enums/EnumUserType.java
  22. +5
    -11
      mallinkService/src/main/java/com/iformall/mapper/WxBusinessCircleOrderMapper.java
  23. +8
    -10
      mallinkService/src/main/java/com/iformall/service/WxBusinessCircleOrderService.java
  24. +16
    -0
      mallinkService/src/main/java/com/iformall/service/WxCallBackService.java
  25. +137
    -48
      mallinkService/src/main/java/com/iformall/service/impl/WxBusinessCircleOrderServiceImpl.java
  26. +55
    -0
      mallinkService/src/main/java/com/iformall/service/impl/WxCallBackServiceImpl.java
  27. +216
    -216
      mallinkService/src/main/java/com/iformall/service/impl/WxThirdPartyOrdersServiceImpl.java
  28. +0
    -172
      mallinkService/src/main/java/com/iformall/service/msg/impl/FmInsideBusinessCircleMsgServiceImpl.java
  29. +0
    -145
      mallinkService/src/main/java/com/iformall/service/msg/impl/FmInsideThirdPartyOrderMsgServiceImpl.java
  30. +37
    -49
      mallinkService/src/main/resources/mapper/WxBusinessCircleOrderMapper.xml

+ 3
- 2
mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponChannelController.java Просмотреть файл

@@ -67,14 +67,15 @@ public class WxCouponChannelController extends BaseController {
wxCouponChannel.setStatus(null); wxCouponChannel.setStatus(null);
} }
wxCouponChannel.updateTenantInfo(getTenantInfo()); wxCouponChannel.updateTenantInfo(getTenantInfo());
wxCouponChannel.setSortColumns(BaseEntity.SortField.CCUpdateDate_DESC);


if(null == wxCouponChannel.getSourceType()){ if(null == wxCouponChannel.getSourceType()){
wxCouponChannel.setSourceType(EnumCouponSourceType.COUPONSource_Admin.getCode()); wxCouponChannel.setSourceType(EnumCouponSourceType.COUPONSource_Admin.getCode());
} }


if(StringUtils.isNotBlank(wxCouponChannel.getSortColumn())){ if(StringUtils.isNotBlank(wxCouponChannel.getSortColumn())){
wxCouponChannel.setSortColumn("cc."+wxCouponChannel.getSortColumn());
//
}else{
wxCouponChannel.setSortColumns(BaseEntity.SortField.CCUpdateDate_DESC);
} }
final PageInfo<WxCouponChannelVo> page = wxCouponChannelService.listPageCVo(wxCouponChannel, pageNum, pageSize); final PageInfo<WxCouponChannelVo> page = wxCouponChannelService.listPageCVo(wxCouponChannel, pageNum, pageSize);
return new ResultData(page); return new ResultData(page);


+ 6
- 2
mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java Просмотреть файл

@@ -74,7 +74,9 @@ public class WxCouponController extends BaseController {
wxCoupon.setSourceType(EnumCouponSourceType.COUPONSource_Admin.getCode()); wxCoupon.setSourceType(EnumCouponSourceType.COUPONSource_Admin.getCode());
} }
if(StringUtils.isNotBlank(wxCoupon.getSortColumn())){ if(StringUtils.isNotBlank(wxCoupon.getSortColumn())){
wxCoupon.setSortColumn("c."+wxCoupon.getSortColumn());
String coryColumn = "c."+wxCoupon.getSortColumns();
wxCoupon.setSortColumn(coryColumn);
wxCoupon.setSortColumn(null);
} }
if(wxCoupon.getTargetAd() != null && wxCoupon.getTargetAd() == EnumCouponChannelType.COUPON_CHANNEL_ID_TIMED.getCode()){ if(wxCoupon.getTargetAd() != null && wxCoupon.getTargetAd() == EnumCouponChannelType.COUPON_CHANNEL_ID_TIMED.getCode()){
Integer[] typeArray = { Integer[] typeArray = {
@@ -111,7 +113,9 @@ public class WxCouponController extends BaseController {


wxCoupon.setTypes(Arrays.asList(typeArray)); wxCoupon.setTypes(Arrays.asList(typeArray));
if(StringUtils.isNotBlank(wxCoupon.getSortColumn())){ if(StringUtils.isNotBlank(wxCoupon.getSortColumn())){
wxCoupon.setSortColumn("c."+wxCoupon.getSortColumn());
String coryColumn = "c."+wxCoupon.getSortColumns();
wxCoupon.setSortColumn(coryColumn);
wxCoupon.setSortColumn(null);
} }
return wxCouponService.list(wxCoupon,wxCoupon, pageNum, pageSize); //全列表 return wxCouponService.list(wxCoupon,wxCoupon, pageNum, pageSize); //全列表
} }


+ 6
- 2
mallinkAdmin/src/main/java/com/iformall/controller/mem/MemCouponController.java Просмотреть файл

@@ -54,10 +54,14 @@ public class MemCouponController extends BaseController {
wxCouponChannel.updateTenantInfo(getTenantInfo()); wxCouponChannel.updateTenantInfo(getTenantInfo());
wxCouponChannel.setTargetAd(EnumCouponChannelType.COUPON_CHANNEL_ID_H5.getCode()); wxCouponChannel.setTargetAd(EnumCouponChannelType.COUPON_CHANNEL_ID_H5.getCode());
wxCouponChannel.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode()); wxCouponChannel.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode());
wxCouponChannel.setSortColumns(BaseEntity.SortField.CCUpdateDate_DESC);


if(StringUtils.isNotBlank(wxCouponChannel.getSortColumn())){ if(StringUtils.isNotBlank(wxCouponChannel.getSortColumn())){
wxCouponChannel.setSortColumn("cc."+wxCouponChannel.getSortColumn());
// String coryColumn = "c."+wxCouponChannel.getSortColumns();
// wxCouponChannel.setSortColumn(coryColumn);
// wxCouponChannel.setSortColumn(null);
}else{
wxCouponChannel.setSortColumns(BaseEntity.SortField.CCUpdateDate_DESC);
} }
final PageInfo<WxCouponChannelVo> page = couponChannelService.listPageCVo(wxCouponChannel, pageNum, pageSize); final PageInfo<WxCouponChannelVo> page = couponChannelService.listPageCVo(wxCouponChannel, pageNum, pageSize);
return new ResultData(page); return new ResultData(page);


+ 501
- 1201
mallinkAdmin/src/main/resources/db/migration/V202104190001__wx_business_circle_order.sql
Разница между файлами не показана из-за своего большого размера
Просмотреть файл


+ 3
- 2
mallinkBApi/src/main/java/com/iformall/controller/WxCouponChannelController.java Просмотреть файл

@@ -60,10 +60,11 @@ public class WxCouponChannelController extends BaseController {
} }
wxCouponChannel.setMerchantId(getLoginBUser().getMerchantId()); wxCouponChannel.setMerchantId(getLoginBUser().getMerchantId());
wxCouponChannel.updateTenantInfo(getTenantInfo()); wxCouponChannel.updateTenantInfo(getTenantInfo());
wxCouponChannel.setSortColumns(BaseEntity.SortField.CCUpdateDate_DESC);


if(StringUtils.isNotBlank(wxCouponChannel.getSortColumn())){ if(StringUtils.isNotBlank(wxCouponChannel.getSortColumn())){
wxCouponChannel.setSortColumn("cc."+wxCouponChannel.getSortColumn());
//
}else{
wxCouponChannel.setSortColumns(BaseEntity.SortField.CCUpdateDate_DESC);
} }
final PageInfo<WxCouponChannelVo> page = wxCouponChannelService.listPageCVo(wxCouponChannel, pageNum, pageSize); final PageInfo<WxCouponChannelVo> page = wxCouponChannelService.listPageCVo(wxCouponChannel, pageNum, pageSize);
return new ResultData(page); return new ResultData(page);


+ 6
- 2
mallinkBApi/src/main/java/com/iformall/controller/WxCouponController.java Просмотреть файл

@@ -71,7 +71,9 @@ public class WxCouponController extends BaseController {
wxCoupon.setMerchantId(getLoginBUser().getMerchantId()); wxCoupon.setMerchantId(getLoginBUser().getMerchantId());


if(StringUtils.isNotBlank(wxCoupon.getSortColumn())){ if(StringUtils.isNotBlank(wxCoupon.getSortColumn())){
wxCoupon.setSortColumn("c."+wxCoupon.getSortColumn());
String coryColumn = "c."+wxCoupon.getSortColumns();
wxCoupon.setSortColumn(coryColumn);
wxCoupon.setSortColumn(null);
} }


return wxCouponService.list(wxCoupon,wxCoupon, pageNum, pageSize); //全列表 return wxCouponService.list(wxCoupon,wxCoupon, pageNum, pageSize); //全列表
@@ -99,7 +101,9 @@ public class WxCouponController extends BaseController {
wxCoupon.setTypes(Arrays.asList(typeArray)); wxCoupon.setTypes(Arrays.asList(typeArray));
wxCoupon.setMerchantId(getLoginBUser().getMerchantId()); wxCoupon.setMerchantId(getLoginBUser().getMerchantId());
if(StringUtils.isNotBlank(wxCoupon.getSortColumn())){ if(StringUtils.isNotBlank(wxCoupon.getSortColumn())){
wxCoupon.setSortColumn("c."+wxCoupon.getSortColumn());
String coryColumn = "c."+wxCoupon.getSortColumns();
wxCoupon.setSortColumn(coryColumn);
wxCoupon.setSortColumn(null);
} }
return wxCouponService.list(wxCoupon,wxCoupon, pageNum, pageSize); //全列表 return wxCouponService.list(wxCoupon,wxCoupon, pageNum, pageSize); //全列表
} }


+ 3
- 3
mallinkCApi/src/main/java/com/iformall/controller/WxCouponChannelController.java Просмотреть файл

@@ -55,10 +55,10 @@ public class WxCouponChannelController extends BaseController {
wxCouponChannel.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode()); wxCouponChannel.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode());
wxCouponChannel.setCouponStatus(EnumCouponStatus.COUPON_STATUS_THROW_IN.getCode()); wxCouponChannel.setCouponStatus(EnumCouponStatus.COUPON_STATUS_THROW_IN.getCode());


wxCouponChannel.setSortColumns(BaseEntity.SortField.CCUpdateDate_DESC, BaseEntity.SortField.CCId_DESC);

if(StringUtils.isNotBlank(wxCouponChannel.getSortColumn())){ if(StringUtils.isNotBlank(wxCouponChannel.getSortColumn())){
wxCouponChannel.setSortColumn("cc."+wxCouponChannel.getSortColumn());

}else{
wxCouponChannel.setSortColumns(BaseEntity.SortField.CCUpdateDate_DESC, BaseEntity.SortField.CCId_DESC);
} }
wxCouponChannel.setShowBeginTime(new Date()); wxCouponChannel.setShowBeginTime(new Date());
PageInfo<WxCouponChannelVo> page = wxCouponChannelService.listPageCVo(wxCouponChannel, pageNum, pageSize); PageInfo<WxCouponChannelVo> page = wxCouponChannelService.listPageCVo(wxCouponChannel, pageNum, pageSize);


+ 12
- 15
mallinkCallback/src/main/java/com/iformall/controller/callback/WxBusinessOrderController.java Просмотреть файл

@@ -82,18 +82,17 @@ public class WxBusinessOrderController extends BaseController {
WxBusinessCircleOrder wxBusinessCircleOrder = new WxBusinessCircleOrder(); WxBusinessCircleOrder wxBusinessCircleOrder = new WxBusinessCircleOrder();
wxBusinessCircleOrder.updateTenantInfo(tenantEntity); wxBusinessCircleOrder.updateTenantInfo(tenantEntity);
wxBusinessCircleOrder.setSourceType(EnumThirdPartyConfigType.WEIXIN.getCode()); wxBusinessCircleOrder.setSourceType(EnumThirdPartyConfigType.WEIXIN.getCode());
wxBusinessCircleOrder.setNoticeId(notifyData.getId());
wxBusinessCircleOrder.setNoticeCreateTime(sdf.parse(notifyData.getCreateTime()));
wxBusinessCircleOrder.setNoticeEventType(notifyData.getEventType());
wxBusinessCircleOrder.setNoticeResourceType(notifyData.getResourceType());
wxBusinessCircleOrder.setSummary(notifyData.getSummary());


//解密 //解密
if(WxPayConstant.NOTICE_EVENT_TYPE.equals(notifyData.getEventType())){ if(WxPayConstant.NOTICE_EVENT_TYPE.equals(notifyData.getEventType())){
PaidResult result = wxPayService.getBusinessCircleService().decryptPaidNotifyDataResource(notifyData); PaidResult result = wxPayService.getBusinessCircleService().decryptPaidNotifyDataResource(notifyData);
logger.info("微信商圈支付成功通知---解密结果{}"+notifyData.toString()); logger.info("微信商圈支付成功通知---解密结果{}"+notifyData.toString());


wxBusinessCircleOrder.setNoticeId(notifyData.getId());
wxBusinessCircleOrder.setNoticeCreateTime(sdf.parse(notifyData.getCreateTime()));
wxBusinessCircleOrder.setNoticeEventType(notifyData.getEventType());
wxBusinessCircleOrder.setNoticeResourceType(notifyData.getResourceType());
wxBusinessCircleOrder.setSummary(notifyData.getSummary());

wxBusinessCircleOrder.setWxMchid(result.getMchid()); wxBusinessCircleOrder.setWxMchid(result.getMchid());
wxBusinessCircleOrder.setWxMerchantName(result.getMerchantName()); wxBusinessCircleOrder.setWxMerchantName(result.getMerchantName());
wxBusinessCircleOrder.setWxShopName(result.getShopName()); wxBusinessCircleOrder.setWxShopName(result.getShopName());
@@ -102,6 +101,7 @@ public class WxBusinessOrderController extends BaseController {
wxBusinessCircleOrder.setOpenid(result.getOpenid()); wxBusinessCircleOrder.setOpenid(result.getOpenid());
wxBusinessCircleOrder.setTimeEnd(sdf.parse(result.getTimeEnd())); wxBusinessCircleOrder.setTimeEnd(sdf.parse(result.getTimeEnd()));
wxBusinessCircleOrder.setAmount(result.getAmount()); wxBusinessCircleOrder.setAmount(result.getAmount());
wxBusinessCircleOrder.setPayAmount(result.getAmount());
wxBusinessCircleOrder.setTransactionId(result.getTransactionId()); wxBusinessCircleOrder.setTransactionId(result.getTransactionId());
wxBusinessCircleOrder.setCommitTag(result.getCommitTag()); wxBusinessCircleOrder.setCommitTag(result.getCommitTag());


@@ -113,24 +113,21 @@ public class WxBusinessOrderController extends BaseController {
RefundResult result = wxPayService.getBusinessCircleService().decryptRefundNotifyDataResource(notifyData); RefundResult result = wxPayService.getBusinessCircleService().decryptRefundNotifyDataResource(notifyData);
logger.info("微信商圈退款成功通知---解密结果{}"+result.toString()); logger.info("微信商圈退款成功通知---解密结果{}"+result.toString());


wxBusinessCircleOrder.setRefundNoticeId(notifyData.getId());
wxBusinessCircleOrder.setRefundCreateTime(sdf.parse(notifyData.getCreateTime()));
wxBusinessCircleOrder.setRefundEventType(notifyData.getEventType());
wxBusinessCircleOrder.setRefundResourceType(notifyData.getResourceType());
wxBusinessCircleOrder.setRefundSummary(notifyData.getSummary());

wxBusinessCircleOrder.setTransactionId(result.getTransactionId());
wxBusinessCircleOrder.setWxMchid(result.getMchid()); wxBusinessCircleOrder.setWxMchid(result.getMchid());
wxBusinessCircleOrder.setWxMerchantName(result.getMerchantName()); wxBusinessCircleOrder.setWxMerchantName(result.getMerchantName());
wxBusinessCircleOrder.setWxShopName(result.getShopName()); wxBusinessCircleOrder.setWxShopName(result.getShopName());
wxBusinessCircleOrder.setWxShopNumber(result.getShopNumber()); wxBusinessCircleOrder.setWxShopNumber(result.getShopNumber());
wxBusinessCircleOrder.setAppid(result.getAppid()); wxBusinessCircleOrder.setAppid(result.getAppid());
wxBusinessCircleOrder.setOpenid(result.getOpenid()); wxBusinessCircleOrder.setOpenid(result.getOpenid());
wxBusinessCircleOrder.setRefundTime(sdf.parse(result.getRefundTime()));
wxBusinessCircleOrder.setTimeEnd(sdf.parse(result.getRefundTime()));
wxBusinessCircleOrder.setAmount(result.getPayAmount());
wxBusinessCircleOrder.setPayAmount(result.getPayAmount());
wxBusinessCircleOrder.setTransactionId(result.getTransactionId());

wxBusinessCircleOrder.setRefundAmount(result.getRefundAmount()); wxBusinessCircleOrder.setRefundAmount(result.getRefundAmount());
wxBusinessCircleOrder.setRefundId(result.getRefundId()); wxBusinessCircleOrder.setRefundId(result.getRefundId());


wxBusinessCircleOrderService.updateRefundOrder(wxBusinessCircleOrder);
wxBusinessCircleOrderService.insertRefundNoticeOrder(wxBusinessCircleOrder);
resultMap.put("code","SUCCESS"); resultMap.put("code","SUCCESS");
return resultMap; return resultMap;
} }


+ 1
- 16
mallinkMQConsumer/src/main/java/com/iformall/mq/MqBaseConsumer.java Просмотреть файл

@@ -48,12 +48,6 @@ public class MqBaseConsumer {
@Autowired @Autowired
private FmInsideCashOutMsgServiceImpl fmInsideCashOutMsgService; private FmInsideCashOutMsgServiceImpl fmInsideCashOutMsgService;

@Autowired
private FmInsideBusinessCircleMsgServiceImpl fmInsideBusinessCircleMsgService;

@Autowired
private FmInsideThirdPartyOrderMsgServiceImpl fmInsideThirdPartyOrderMsgService;




@@ -123,16 +117,7 @@ public class MqBaseConsumer {
//} //}
//baseMsg.setMsgStatus(EnumMsgRecordStatus.CONSUME_SUCC.getCode()); //baseMsg.setMsgStatus(EnumMsgRecordStatus.CONSUME_SUCC.getCode());
//wxMsgRecordMapper.updateByBaseMsg(baseMsg); //wxMsgRecordMapper.updateByBaseMsg(baseMsg);
else if(EnumMsgRecordType.BUSINESS_CIRCLE_NOTICE.getCode().equals(baseMsg.getMsgType())) {
// 微信商圈内部通知
FmInsideCircleOrderMsg msg = (FmInsideCircleOrderMsg)JsonUtil.readValue(message, FmInsideCircleOrderMsg.class);
fmInsideBusinessCircleMsgService.send(msg);
}
else if(EnumMsgRecordType.THIRD_PARTY_NOTICE.getCode().equals(baseMsg.getMsgType())) {
// 第三方订单内部通知
FmInsideCircleOrderMsg msg = (FmInsideCircleOrderMsg)JsonUtil.readValue(message, FmInsideCircleOrderMsg.class);
fmInsideThirdPartyOrderMsgService.send(msg);
}

}catch (Throwable e){ }catch (Throwable e){
log.error("consum received error: ", e); log.error("consum received error: ", e);
/** /**


+ 0
- 40
mallinkPublicApi/src/main/java/com/iformall/controller/UserBasicInfoController.java Просмотреть файл

@@ -1,6 +1,5 @@
package com.iformall.controller; package com.iformall.controller;


import com.alibaba.fastjson.JSON;
import com.iformall.common.ErrorCode; import com.iformall.common.ErrorCode;
import com.iformall.common.ResultData; import com.iformall.common.ResultData;
import com.iformall.domain.po.WxCUserBasicInfo; import com.iformall.domain.po.WxCUserBasicInfo;
@@ -8,8 +7,6 @@ import com.iformall.domain.po.WxLevelConfig;
import com.iformall.domain.po.base.TenantEntity; import com.iformall.domain.po.base.TenantEntity;
import com.iformall.service.WxCUserBasicInfoService; import com.iformall.service.WxCUserBasicInfoService;
import com.iformall.service.WxLevelConfigService; import com.iformall.service.WxLevelConfigService;
import com.iformall.utils.HttpUtil;
import com.iformall.utils.sign.SignUtils;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;


@@ -19,8 +16,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;


import java.util.Date;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;


@@ -72,39 +67,4 @@ public class UserBasicInfoController extends BaseController {
return new ResultData(userBasicInfo); return new ResultData(userBasicInfo);
} }










public static void main(String[] args) {

String appId = "CP6nwHvZ";
String appKey = "b257eb97bb9380714306a077a66086e8b1f10639";
String signKey = "C61842C8570524AA81756C53B8096978A06AE00D";

Map<String,String> headMap = new HashMap<>();
headMap.put("appkey",appId+"&"+appKey);

Map<String,Object> paramMap = new HashMap<>();
String timeStamp = Long.toString(new Date().getTime());
System.out.println("timeStamp="+timeStamp);
paramMap.put("timeStamp",timeStamp);//当前时间戳
paramMap.put("phone","17600000000");

String sign = SignUtils.getSign(signKey, paramMap, "MD5");
System.out.println("sign="+sign);
headMap.put("sign",sign);

String s = HttpUtil.doPost("https://openapitest.malls.iformall.com/api/api/userInfo/register", headMap, JSON.toJSONString(paramMap));

System.out.println(s);

}


} }

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

+ 73
- 0
mallinkPublicApi/src/main/java/com/iformall/utils/AppTest.java Просмотреть файл

@@ -0,0 +1,73 @@
package com.iformall.utils;

import com.alibaba.fastjson.JSON;
import com.iformall.common.IdWorker;
import com.iformall.utils.sign.SignUtils;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
* @author gongbiao
*/
public class AppTest {

public static void main(String[] args) {
// AppUtils.main(args);

String appId = "CP6nwHvZ";
String appKey = "b257eb97bb9380714306a077a66086e8b1f10639";
String signKey = "C61842C8570524AA81756C53B8096978A06AE00D";

Map<String,String> headMap = new HashMap<>();
headMap.put("appkey",appId+"&"+appKey);

Map<String,Object> paramMap = new HashMap<>();
String timeStamp = Long.toString(new Date().getTime());
System.out.println("timeStamp="+timeStamp);
paramMap.put("timeStamp",timeStamp);//当前时间戳

/**
* 注册并查询用户详细信息 参数
*/
// paramMap.put("phone","17600293031");

/**
* 创建交易信息 参数
*/
IdWorker idWorker = IdWorker.get();
paramMap.put("transactionId",String.valueOf(idWorker.nextId()));//***订单Id
paramMap.put("shopNumber","461675336101793792");//***门店唯一标识 对应双方平台门店
paramMap.put("shopName","百丽");//门店名称
paramMap.put("userNumber","542490555719278592");//***会员Id
paramMap.put("userPhone","18872592633");//会员手机号
paramMap.put("timeEnd","2021-04-26 11:43:00");//***付款时间(yyyy-MM-dd HH:mm:ss)
paramMap.put("amount","1000");//***付款金额(分)
paramMap.put("summary","我要加积分");//付款摘要


/**
* 参数加密并封装
*/
String sign = SignUtils.getSign(signKey, paramMap, "MD5");
System.out.println("sign="+sign);
headMap.put("sign",sign);


/**
* 注册并查询用户详细信息 接口
*/
// String s = HttpUtil.doPost("https://openapitest.malls.iformall.com/api/userInfo/register", headMap, JSON.toJSONString(paramMap));

/**
* 创建交易信息 接口
*/
String s = HttpUtil.doPost("https://openapitest.malls.iformall.com/api/thirdCircle/order", headMap, JSON.toJSONString(paramMap));


System.out.println(s);

}

}

+ 26
- 0
mallinkService/src/main/java/com/iformall/domain/po/AliBusinessCircleOrder.java Просмотреть файл

@@ -0,0 +1,26 @@
package com.iformall.domain.po;

import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

@TableName(value = "ali_business_circle_order")
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class AliBusinessCircleOrder extends BusinessCircleBase {

@io.swagger.annotations.ApiModelProperty(value="发生交易的商圈(非商圈组)的商圈唯一标识号",name="mallId")
private String mallId;

@io.swagger.annotations.ApiModelProperty(value="发生交易的商圈(非商圈组)的名称",name="mallName")
private String mallName;

@io.swagger.annotations.ApiModelProperty(value="门店编号,商户侧系统内编号",name="mallStoreId")
private String mallStoreId;

@io.swagger.annotations.ApiModelProperty(value="支付宝用户Id",name="buyerId")
private String buyerId;

}

+ 138
- 0
mallinkService/src/main/java/com/iformall/domain/po/BusinessCircleBase.java Просмотреть файл

@@ -0,0 +1,138 @@
package com.iformall.domain.po;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.iformall.domain.po.base.TenantEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

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

@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class BusinessCircleBase extends TenantEntity {

protected Long id;

@TableField(exist = false)
@io.swagger.annotations.ApiModelProperty(value="来源类型(1:来自微信)",name="sourceType")
private Integer sourceType;

@io.swagger.annotations.ApiModelProperty(value="商圈支付结果通知Id",name="noticeId")
private String noticeId;

@io.swagger.annotations.ApiModelProperty(value="商圈支付结果通知创建时间",name="noticeCreateTime")
private Date noticeCreateTime;

@io.swagger.annotations.ApiModelProperty(value="商圈支付结果通知类型:MALL_TRANSACTION.SUCCESS",name="noticeEventType")
private String noticeEventType;

@io.swagger.annotations.ApiModelProperty(value="商圈支付结果通知资源数据类型:encrypt-resource",name="noticeResourceType")
private String noticeResourceType;

@io.swagger.annotations.ApiModelProperty(value="商圈支付结果通知回调摘要",name="summary")
private String summary;

@io.swagger.annotations.ApiModelProperty(value="微信支付分配的商户号",name="wxMchid")
private String wxMchid;

@io.swagger.annotations.ApiModelProperty(value="商圈商户名称",name="wxMerchantName")
private String wxMerchantName;

@io.swagger.annotations.ApiModelProperty(value="门店名称,商圈在商圈小程序上圈店时填写的门店名称",name="wxShopName")
private String wxShopName;

@io.swagger.annotations.ApiModelProperty(value="门店编号,商圈在商圈小程序上圈店时填写的门店编号,用于跟商圈自身已有的商户识别码对齐",name="wxShopNumber")
private String wxShopNumber;

@io.swagger.annotations.ApiModelProperty(value="小程序appid",name="appid")
private String appid;

@io.swagger.annotations.ApiModelProperty(value="openid",name="openid")
private String openid;

@io.swagger.annotations.ApiModelProperty(value="交易完成时间",name="timeEnd")
private Date timeEnd;

@io.swagger.annotations.ApiModelProperty(value="用户实际消费金额,单位(分)",name="amount")
private Integer amount;

@TableField(exist = false)
@io.swagger.annotations.ApiModelProperty(value="用户实际消费金额,单位(元)",name="amountStr")
private String amountStr;

public String getAmountStr() {
return amount != null ? new BigDecimal(amount).divide(new BigDecimal(100)).toPlainString(): amountStr;
}

@io.swagger.annotations.ApiModelProperty(value="用户实际付款金额,单位(分)",name="payAmount")
private Integer payAmount;

@TableField(exist = false)
@io.swagger.annotations.ApiModelProperty(value="用户实际付款金额,单位(元)",name="payAmountStr")
private String payAmountStr;

public String getPayAmountStr() {
return payAmount != null ? new BigDecimal(payAmount).divide(new BigDecimal(100)).toPlainString(): payAmountStr;
}

@io.swagger.annotations.ApiModelProperty(value="支付订单号",name="transactionId")
private String transactionId;

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

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

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

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

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

@io.swagger.annotations.ApiModelProperty(value="是否获得积分(1:是,0:否)",name="earnPoints")
private Integer earnPoints;

@io.swagger.annotations.ApiModelProperty(value="订单更新积分值",name="increasedPoints")
private Integer increasedPoints;

@io.swagger.annotations.ApiModelProperty(value="积分更新时间(新增)",name="increasedPoints")
private Date pointsUpdateTime;

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


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

@io.swagger.annotations.ApiModelProperty(value="微信支付退款单号",name="refundId")
private String refundId;

@TableField(exist = false)
@io.swagger.annotations.ApiModelProperty(value="查询-开始时间",name="startdate")
private Date startTime;

@TableField(exist = false)
@io.swagger.annotations.ApiModelProperty(value="查询-结束时间",name="enddate")
private Date endTime;

@io.swagger.annotations.ApiModelProperty(value="用户退款金额,单位(分)",name="refundAmount")
private Integer refundAmount;

@TableField(exist = false)
@io.swagger.annotations.ApiModelProperty(value="用户退款金额,单位(元)",name="refundAmountStr")
private String refundAmountStr;

public String getRefundAmountStr() {
return refundAmount != null ? new BigDecimal(refundAmount).divide(new BigDecimal(100)).toPlainString(): refundAmountStr;
}

}

+ 1
- 116
mallinkService/src/main/java/com/iformall/domain/po/WxBusinessCircleOrder.java Просмотреть файл

@@ -1,40 +1,15 @@
package com.iformall.domain.po; package com.iformall.domain.po;


import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.iformall.domain.po.base.TenantEntity;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.ToString; import lombok.ToString;


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

@TableName(value = "wx_business_circle_order") @TableName(value = "wx_business_circle_order")
@Data @Data
@ToString(callSuper = true) @ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
public class WxBusinessCircleOrder extends TenantEntity {

protected Long id;

@io.swagger.annotations.ApiModelProperty(value="来源类型(1:来自微信)",name="sourceType")
private Integer sourceType;

@io.swagger.annotations.ApiModelProperty(value="商圈支付结果通知Id",name="noticeId")
private String noticeId;

@io.swagger.annotations.ApiModelProperty(value="商圈支付结果通知创建时间",name="noticeCreateTime")
private Date noticeCreateTime;

@io.swagger.annotations.ApiModelProperty(value="商圈支付结果通知类型:MALL_TRANSACTION.SUCCESS",name="noticeEventType")
private String noticeEventType;

@io.swagger.annotations.ApiModelProperty(value="商圈支付结果通知资源数据类型:encrypt-resource",name="noticeResourceType")
private String noticeResourceType;

@io.swagger.annotations.ApiModelProperty(value="商圈支付结果通知回调摘要",name="summary")
private String summary;
public class WxBusinessCircleOrder extends BusinessCircleBase {


@io.swagger.annotations.ApiModelProperty(value="微信支付分配的商户号",name="wxMchid") @io.swagger.annotations.ApiModelProperty(value="微信支付分配的商户号",name="wxMchid")
private String wxMchid; private String wxMchid;
@@ -54,100 +29,10 @@ public class WxBusinessCircleOrder extends TenantEntity {
@io.swagger.annotations.ApiModelProperty(value="openid",name="openid") @io.swagger.annotations.ApiModelProperty(value="openid",name="openid")
private String openid; private String openid;


@io.swagger.annotations.ApiModelProperty(value="交易完成时间",name="timeEnd")
private Date timeEnd;

@io.swagger.annotations.ApiModelProperty(value="用户实际消费金额,单位(分)",name="amount")
private Integer amount;

@TableField(exist = false)
@io.swagger.annotations.ApiModelProperty(value="用户实际消费金额,单位(元)",name="amount")
private String amountStr;

public String getAmountStr() {
return amount != null ? new BigDecimal(amount).divide(new BigDecimal(100)).toPlainString(): amountStr;
}

@io.swagger.annotations.ApiModelProperty(value="支付订单号",name="transactionId")
private String transactionId;

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


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

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

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

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

@io.swagger.annotations.ApiModelProperty(value="是否获得积分(1:是,0:否)",name="earnPoints")
private Integer earnPoints;

@io.swagger.annotations.ApiModelProperty(value="订单新增积分值",name="increasedPoints")
private Integer increasedPoints;

@io.swagger.annotations.ApiModelProperty(value="积分更新时间(新增)",name="increasedPoints")
private Date pointsUpdateTime;

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



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


@io.swagger.annotations.ApiModelProperty(value="退款通知唯一ID",name="refundNoticeId")
private String refundNoticeId;

@io.swagger.annotations.ApiModelProperty(value="退款通知创建时间",name="refundCreateTime")
private Date refundCreateTime;

@io.swagger.annotations.ApiModelProperty(value="退款通知的类型为:MALL_REFUND.SUCCESS",name="refundEventType")
private String refundEventType;

@io.swagger.annotations.ApiModelProperty(value="退款通知的资源数据类型",name="refundResourceType")
private String refundResourceType;

@io.swagger.annotations.ApiModelProperty(value="退款回调摘要",name="refundSummary")
private String refundSummary;

@io.swagger.annotations.ApiModelProperty(value="退款完成时间",name="refundTime")
private Date refundTime;

@io.swagger.annotations.ApiModelProperty(value="用户退款金额,单位(分)",name="refundSummary")
private Integer refundAmount;

@TableField(exist = false)
@io.swagger.annotations.ApiModelProperty(value="用户退款金额,单位(元)",name="amount")
private String refundAmountStr;

public String getRefundAmountStr() {
return refundAmount != null ? new BigDecimal(refundAmount).divide(new BigDecimal(100)).toPlainString(): refundAmountStr;
}

@io.swagger.annotations.ApiModelProperty(value="微信支付退款单号",name="refundId")
private String refundId;

@io.swagger.annotations.ApiModelProperty(value="用户是否退积分(1:是,0:否)",name="isRefundPoints")
private Integer isRefundPoints;

@io.swagger.annotations.ApiModelProperty(value="用户退积分时间",name="refundPointsTime")
private Date refundPointsTime;



@TableField(exist = false)
@io.swagger.annotations.ApiModelProperty(value="查询-开始时间",name="startdate")
private Date startTime;

@TableField(exist = false)
@io.swagger.annotations.ApiModelProperty(value="查询-结束时间",name="enddate")
private Date endTime;
} }

+ 1
- 83
mallinkService/src/main/java/com/iformall/domain/po/WxThirdPartyOrders.java Просмотреть файл

@@ -14,9 +14,7 @@ import java.util.Date;
@Data @Data
@ToString(callSuper = true) @ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
public class WxThirdPartyOrders extends TenantEntity {

protected Long id;
public class WxThirdPartyOrders extends BusinessCircleBase {


@io.swagger.annotations.ApiModelProperty(value="来源(wx_third_party_api)",name="sourceAppId") @io.swagger.annotations.ApiModelProperty(value="来源(wx_third_party_api)",name="sourceAppId")
private String sourceAppId; private String sourceAppId;
@@ -36,84 +34,4 @@ public class WxThirdPartyOrders extends TenantEntity {
@io.swagger.annotations.ApiModelProperty(value="顾客编号",name="userNumber") @io.swagger.annotations.ApiModelProperty(value="顾客编号",name="userNumber")
private String userNumber; private String userNumber;


@io.swagger.annotations.ApiModelProperty(value="交易完成时间",name="timeEnd")
private Date timeEnd;

@io.swagger.annotations.ApiModelProperty(value="用户实际消费金额,单位(分)",name="amount")
private Integer amount;

@TableField(exist = false)
@io.swagger.annotations.ApiModelProperty(value="用户实际消费金额,单位(元)",name="amount")
private String amountStr;

public String getAmountStr() {
return amount != null ? new BigDecimal(amount).divide(new BigDecimal(100)).toPlainString(): amountStr;
}

@io.swagger.annotations.ApiModelProperty(value="支付订单号",name="transactionId")
private String transactionId;

@io.swagger.annotations.ApiModelProperty(value="订单摘要",name="summary")
private String summary;

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

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

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

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

@io.swagger.annotations.ApiModelProperty(value="是否获得积分(1:是,0:否)",name="earnPoints")
private Integer earnPoints;

@io.swagger.annotations.ApiModelProperty(value="订单新增积分值",name="increasedPoints")
private Integer increasedPoints;

@io.swagger.annotations.ApiModelProperty(value="积分更新时间(新增)",name="increasedPoints")
private Date pointsUpdateTime;


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

@io.swagger.annotations.ApiModelProperty(value="退款摘要",name="refundSummary")
private String refundSummary;

@io.swagger.annotations.ApiModelProperty(value="退款完成时间",name="refundTime")
private Date refundTime;

@io.swagger.annotations.ApiModelProperty(value="用户退款金额,单位(分)",name="refundSummary")
private Integer refundAmount;

@TableField(exist = false)
@io.swagger.annotations.ApiModelProperty(value="用户退款金额,单位(元)",name="amount")
private String refundAmountStr;

public String getRefundAmountStr() {
return refundAmount != null ? new BigDecimal(refundAmount).divide(new BigDecimal(100)).toPlainString(): refundAmountStr;
}

@io.swagger.annotations.ApiModelProperty(value="退款单号",name="refundId")
private String refundId;

@io.swagger.annotations.ApiModelProperty(value="用户是否退积分(1:是,0:否)",name="isRefundPoints")
private Integer isRefundPoints;

@io.swagger.annotations.ApiModelProperty(value="用户退积分时间",name="refundPointsTime")
private Date refundPointsTime;



@TableField(exist = false)
@io.swagger.annotations.ApiModelProperty(value="查询-开始时间",name="startdate")
private Date startTime;

@TableField(exist = false)
@io.swagger.annotations.ApiModelProperty(value="查询-结束时间",name="enddate")
private Date endTime;
} }

+ 6
- 0
mallinkService/src/main/java/com/iformall/domain/po/base/BaseEntity.java Просмотреть файл

@@ -130,6 +130,12 @@ public class BaseEntity implements Serializable {


} }


public void setSortColumns(String sortColumns)
{
this.sortColumns=sortColumns;

}

public enum SortField { public enum SortField {
Id_ASC("`id` ASC"), Id_ASC("`id` ASC"),
Id_DESC("`id` DESC"), Id_DESC("`id` DESC"),


+ 0
- 7
mallinkService/src/main/java/com/iformall/domain/po/base/BaseTenantEntity.java Просмотреть файл

@@ -47,10 +47,6 @@ public class BaseTenantEntity extends BaseEntity {
} }
return shardFinalTableSuffix; return shardFinalTableSuffix;
} }
@TableField(exist = false)
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
private TenantEntity tenantInfo;


public void updateTenantInfo(TenantEntity info) { public void updateTenantInfo(TenantEntity info) {
log.info("info.tenantId:"+info.getTenantId()+". info.parentTenantId:"+info.getParentTenantId()+"."); log.info("info.tenantId:"+info.getTenantId()+". info.parentTenantId:"+info.getParentTenantId()+".");
@@ -91,7 +87,4 @@ public class BaseTenantEntity extends BaseEntity {
this.parentTenantId = parentTenantId; this.parentTenantId = parentTenantId;
} }


public void setTenantInfo(TenantEntity tenantInfo) {
this.tenantInfo = tenantInfo;
}
} }

+ 0
- 35
mallinkService/src/main/java/com/iformall/domain/po/msg/FmInsideCircleOrderMsg.java Просмотреть файл

@@ -1,35 +0,0 @@
package com.iformall.domain.po.msg;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class FmInsideCircleOrderMsg extends BaseMsg{
private static final long serialVersionUID = 1L;

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

@io.swagger.annotations.ApiModelProperty(value="第三方订单对应己方Id",name="circleOrderId")
private Long circleOrderId;

@io.swagger.annotations.ApiModelProperty(value="门店Id",name="merchantId")
private Long merchantId;

@io.swagger.annotations.ApiModelProperty(value="c端会员id",name="cUserId")
private Long cUserId;

@io.swagger.annotations.ApiModelProperty(value="门店名称",name="shopName")
private String shopName;

@io.swagger.annotations.ApiModelProperty(value="顾客手机号",name="userPhone")
private String userPhone;

@io.swagger.annotations.ApiModelProperty(value="用户实际消费金额,单位(分)",name="amount")
private Integer amount;


}

+ 0
- 2
mallinkService/src/main/java/com/iformall/enums/EnumMsgRecordType.java Просмотреть файл

@@ -20,8 +20,6 @@ public enum EnumMsgRecordType {
INSIDE_NOTIFY_REFUND_SUCCESS(104, "微信退款回调"), INSIDE_NOTIFY_REFUND_SUCCESS(104, "微信退款回调"),
COUPON_STOCK(105, "券库存更新"), COUPON_STOCK(105, "券库存更新"),
CASH_OUT(106,"商户提现"), CASH_OUT(106,"商户提现"),
BUSINESS_CIRCLE_NOTICE(1000, "商圈订单通知"),//内部消息,加减积分+积分同步
THIRD_PARTY_NOTICE(1001, "第三方订单通知"),//内部消息,加减积分+积分同步
; ;


public static EnumMsgRecordType getEnum(Integer code) { public static EnumMsgRecordType getEnum(Integer code) {


+ 2
- 1
mallinkService/src/main/java/com/iformall/enums/EnumUserType.java Просмотреть файл

@@ -8,7 +8,8 @@ public enum EnumUserType {
MALLUSER(4, "A端用户"), MALLUSER(4, "A端用户"),


BUSINESS_CIRCLE(100, "微信商圈"), BUSINESS_CIRCLE(100, "微信商圈"),
THIRD_CIRCLE(101, "第三方")
ALI_CIRCLE(101, "支付宝商圈"),
THIRD_CIRCLE(102, "第三方")
; ;


public static EnumUserType getEnum(Integer code) { public static EnumUserType getEnum(Integer code) {


+ 5
- 11
mallinkService/src/main/java/com/iformall/mapper/WxBusinessCircleOrderMapper.java Просмотреть файл

@@ -11,7 +11,8 @@ public interface WxBusinessCircleOrderMapper extends CommonMapper<WxBusinessCirc


WxBusinessCircleOrder getById(WxBusinessCircleOrder record); WxBusinessCircleOrder getById(WxBusinessCircleOrder record);


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


/** /**
* 成功通知新建 * 成功通知新建
@@ -23,7 +24,7 @@ public interface WxBusinessCircleOrderMapper extends CommonMapper<WxBusinessCirc
* 加积分 * 加积分
* @param record * @param record
*/ */
void updateAddPoints(WxBusinessCircleOrder record);
void updatePoints(WxBusinessCircleOrder record);


/** /**
* 积分同步状态修改 * 积分同步状态修改
@@ -31,16 +32,9 @@ public interface WxBusinessCircleOrderMapper extends CommonMapper<WxBusinessCirc
void updateIsPointsNotify(WxBusinessCircleOrder record); void updateIsPointsNotify(WxBusinessCircleOrder record);


/** /**
* 退款
* 退款通知新建
* @param record * @param record
*/ */
void updateRefundNoticeOrder(WxBusinessCircleOrder record);

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

void insertRefundNoticeOrder(WxBusinessCircleOrder record);


} }

+ 8
- 10
mallinkService/src/main/java/com/iformall/service/WxBusinessCircleOrderService.java Просмотреть файл

@@ -2,6 +2,9 @@ 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.WxBusinessCircleOrder;
import org.springframework.scheduling.annotation.Async;

import java.util.List;


public interface WxBusinessCircleOrderService { public interface WxBusinessCircleOrderService {


@@ -28,28 +31,23 @@ public interface WxBusinessCircleOrderService {
* @param * @param
* @return * @return
*/ */
WxBusinessCircleOrder getByTransactionId(String transactionId, String tenantId);
WxBusinessCircleOrder getOrderByTransactionId(String transactionId, String tenantId);
List<WxBusinessCircleOrder> getRefundOrderByTransactionId(String transactionId, String tenantId);


void createOrder(WxBusinessCircleOrder record); void createOrder(WxBusinessCircleOrder record);


void updateRefundOrder(WxBusinessCircleOrder record);
void insertRefundNoticeOrder(WxBusinessCircleOrder record);


/** /**
* 积分
* 更新积分
* @param record * @param record
*/ */
void updateAddPoints(WxBusinessCircleOrder record);
void updatePoints(WxBusinessCircleOrder record);


/** /**
* 积分同步状态修改 * 积分同步状态修改
*/ */
void updateIsPointsNotify(WxBusinessCircleOrder record); void updateIsPointsNotify(WxBusinessCircleOrder record);


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



} }

+ 16
- 0
mallinkService/src/main/java/com/iformall/service/WxCallBackService.java Просмотреть файл

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

import com.iformall.domain.po.WxBusinessCircleOrder;
import org.springframework.scheduling.annotation.Async;


public interface WxCallBackService {

/**
* 积分同步
* @param record
*/
@Async
void notifyPoints(WxBusinessCircleOrder record);

}

+ 137
- 48
mallinkService/src/main/java/com/iformall/service/impl/WxBusinessCircleOrderServiceImpl.java Просмотреть файл

@@ -5,26 +5,32 @@ import com.github.pagehelper.PageInfo;
import com.iformall.common.IdWorker; import com.iformall.common.IdWorker;
import com.iformall.domain.po.WxBusinessCircleOrder; import com.iformall.domain.po.WxBusinessCircleOrder;
import com.iformall.domain.po.WxCUser; import com.iformall.domain.po.WxCUser;
import com.iformall.domain.po.WxCreditHistory;
import com.iformall.domain.po.WxMerchant; import com.iformall.domain.po.WxMerchant;
import com.iformall.domain.po.msg.FmInsideCircleOrderMsg;
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.mq.MqBaseProducer;
import com.iformall.service.WxBusinessCircleOrderService;
import com.iformall.service.WxCUserService;
import com.iformall.service.WxMerchantService;
import com.iformall.service.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;


import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
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());
@Autowired

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


@Autowired
WxBusinessCircleOrderMapper wxBusinessCircleOrderMapper; WxBusinessCircleOrderMapper wxBusinessCircleOrderMapper;


@Autowired @Autowired
@@ -33,6 +39,15 @@ public class WxBusinessCircleOrderServiceImpl implements WxBusinessCircleOrderSe
@Autowired @Autowired
WxCUserService wxCUserService; WxCUserService wxCUserService;


@Autowired
WxCreditHistoryService creditHistoryService;

@Autowired
WxPayAccountService wxPayAccountService;

@Autowired
WxCallBackService wxCallBackService;

@Autowired @Autowired
MqBaseProducer mqBaseProducer; MqBaseProducer mqBaseProducer;


@@ -51,18 +66,26 @@ public class WxBusinessCircleOrderServiceImpl implements WxBusinessCircleOrderSe
} }


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

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


@Override @Override
public void createOrder(WxBusinessCircleOrder record) { public void createOrder(WxBusinessCircleOrder record) {
WxBusinessCircleOrder byTransactionId = wxBusinessCircleOrderMapper.getByTransactionId(record);
WxBusinessCircleOrder byTransactionId = this.getOrderByTransactionId(record.getTransactionId(),record.getTenantId());
if(byTransactionId != null){ if(byTransactionId != null){
logger.error("--商圈付款--通知消息已存在---byTransactionId="+byTransactionId.getTransactionId());
logger.error("--商圈付款--订单消息已存在---byTransactionId="+byTransactionId.getTransactionId());
}else{ }else{
Date now = new Date(); Date now = new Date();
final IdWorker idWorker = IdWorker.get(); final IdWorker idWorker = IdWorker.get();
@@ -89,49 +112,121 @@ public class WxBusinessCircleOrderServiceImpl implements WxBusinessCircleOrderSe
} }
wxBusinessCircleOrderMapper.insertNoticeOrder(record); wxBusinessCircleOrderMapper.insertNoticeOrder(record);


this.sendMessage(record,EnumYesOrNo.NO.getCode());
}
}
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.BUSINESS_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.getWxShopName()+"] ("+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);


/**
*
* @param record
* @param isRefund 是否退款
*/
private void sendMessage(WxBusinessCircleOrder record,Integer isRefund){
FmInsideCircleOrderMsg msg = new FmInsideCircleOrderMsg();
msg.setMsgType(EnumMsgRecordType.BUSINESS_CIRCLE_NOTICE.getCode());
msg.updateTenantInfo(record);
msg.setIsRefund(isRefund);
msg.setCircleOrderId(record.getId());
msg.setMerchantId(record.getMerchantId());
msg.setCUserId(record.getCUserId());
msg.setShopName(record.getWxShopName());
msg.setAmount(record.getAmount());
mqBaseProducer.sendMessage(msg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode());
//同步积分
wxCallBackService.notifyPoints(record);

}
} }


@Override @Override
public void updateRefundOrder(WxBusinessCircleOrder record) {
WxBusinessCircleOrder byTransactionId = this.getByTransactionId(record.getTransactionId(),record.getTenantId());
if(byTransactionId == null){
public void insertRefundNoticeOrder(WxBusinessCircleOrder record) {
WxBusinessCircleOrder order = this.getOrderByTransactionId(record.getTransactionId(),record.getTenantId());
if(order == null){
logger.error("--商圈退款--付款消息未找到--transactionId="+record.getTransactionId()); logger.error("--商圈退款--付款消息未找到--transactionId="+record.getTransactionId());
}else if(byTransactionId.getIsRefund().equals(EnumYesOrNo.YES.getCode())){
logger.error("--商圈退款--已是退款状态--transactionId="+record.getTransactionId());
}else{ }else{
Date now = new Date();
record.setId(byTransactionId.getId());
record.setUpdateTime(now);
wxBusinessCircleOrderMapper.updateRefundNoticeOrder(record);

this.sendMessage(record,EnumYesOrNo.YES.getCode());
List<WxBusinessCircleOrder> 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 (WxBusinessCircleOrder ro:refundOrders) {
refundAmount += ro.getRefundAmount();
refundIncreasedPoints += ro.getIncreasedPoints();
}
}
if(refundAmount >= amount){
logger.error("--商圈退款--已经退款--transactionId="+record.getTransactionId());
}else if((refundAmount + record.getRefundAmount()) > amount ){
logger.error("--商圈退款--退款金额超限--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());
wxBusinessCircleOrderMapper.insertRefundNoticeOrder(record);

if(order.getEarnPoints().equals(EnumYesOrNo.YES.getCode())){
WxCreditHistory creditHistory = new WxCreditHistory();
creditHistory.setTenantId(record.getFinalTenantId());
creditHistory.setOperatorType(EnumUserType.BUSINESS_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.getWxShopName()+"] ("+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 @Override
public void updateAddPoints(WxBusinessCircleOrder record) {
public void updatePoints(WxBusinessCircleOrder record) {
record.setUpdateTime(new Date()); record.setUpdateTime(new Date());
wxBusinessCircleOrderMapper.updateAddPoints(record);
wxBusinessCircleOrderMapper.updatePoints(record);
} }


@Override @Override
@@ -140,11 +235,5 @@ public class WxBusinessCircleOrderServiceImpl implements WxBusinessCircleOrderSe
wxBusinessCircleOrderMapper.updateIsPointsNotify(record); wxBusinessCircleOrderMapper.updateIsPointsNotify(record);
} }


@Override
public void updateRefundPoints(WxBusinessCircleOrder record) {
record.setUpdateTime(new Date());
wxBusinessCircleOrderMapper.updateRefundPoints(record);
}



} }

+ 55
- 0
mallinkService/src/main/java/com/iformall/service/impl/WxCallBackServiceImpl.java Просмотреть файл

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

import com.github.binarywang.wxpay.bean.businesscircle.PointsNotifyRequest;
import com.github.binarywang.wxpay.exception.WxPayException;
import com.github.binarywang.wxpay.service.WxPayService;
import com.iformall.domain.po.WxBusinessCircleOrder;
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.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

@Service
public class WxCallBackServiceImpl implements WxCallBackService {

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
WxPayAccountService wxPayAccountService;

@Autowired
WxBusinessCircleOrderService wxBusinessCircleOrderService;

/**
*
* @param record
*/
public void notifyPoints(WxBusinessCircleOrder record){

WxPayService wxPayService = wxPayAccountService.getWxPayService(record.getTenantId());

PointsNotifyRequest request = new PointsNotifyRequest();
request.setSubMchid(wxPayService.getConfig().getSubMchId());
request.setTransactionId(record.getTransactionId());
request.setOpenid(record.getOpenid());
request.setEarnPoints(true);
request.setIncreasedPoints(record.getIncreasedPoints());
request.setPointsUpdateTime(sdf.format(new Date()));

try {
String result = wxPayService.getBusinessCircleService().notifyPoints(request);
logger.info("微信商圈同步积分请求结果----"+result);
wxBusinessCircleOrderService.updateIsPointsNotify(record);
} catch (WxPayException e) {
e.printStackTrace();
}
}

}

+ 216
- 216
mallinkService/src/main/java/com/iformall/service/impl/WxThirdPartyOrdersServiceImpl.java Просмотреть файл

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

+ 0
- 172
mallinkService/src/main/java/com/iformall/service/msg/impl/FmInsideBusinessCircleMsgServiceImpl.java Просмотреть файл

@@ -1,172 +0,0 @@
package com.iformall.service.msg.impl;

import com.github.binarywang.wxpay.bean.businesscircle.PointsNotifyRequest;
import com.github.binarywang.wxpay.service.WxPayService;
import com.iformall.domain.po.WxBusinessCircleOrder;
import com.iformall.domain.po.WxCUserBasicInfo;
import com.iformall.domain.po.WxCreditHistory;
import com.iformall.domain.po.WxMerchant;
import com.iformall.domain.po.msg.BaseMsg;
import com.iformall.domain.po.msg.FmInsideCircleOrderMsg;
import com.iformall.enums.EnumBusiness;
import com.iformall.enums.EnumScoreType;
import com.iformall.enums.EnumUserType;
import com.iformall.enums.EnumYesOrNo;
import com.iformall.service.*;
import com.iformall.service.msg.MsgSendService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

/**
*
*
*/
@Service
public class FmInsideBusinessCircleMsgServiceImpl implements MsgSendService {

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
WxMerchantService wxMerchantService;

@Autowired
WxCreditHistoryService creditHistoryService;

@Autowired
WxCUserBasicInfoService cUserBasicInfoService;

@Autowired
WxBusinessCircleOrderService businessCircleOrderService;

@Autowired
WxPayAccountService wxPayAccountService;

@Override
public void send(BaseMsg baseMsg) throws Exception {
FmInsideCircleOrderMsg msg = (FmInsideCircleOrderMsg)baseMsg;
logger.info("FmInsideBusinessCircleMsgServiceImpl---{}"+msg.toString());
if(msg.getCUserId() == null){
return;
}
WxCUserBasicInfo user = cUserBasicInfoService.getById(msg.getCUserId(), msg.getFinalTenantId());
if(user == null){
return;
}

WxBusinessCircleOrder wxBusinessCircleOrder = businessCircleOrderService.getById(msg.getCircleOrderId(),msg.getTenantId());
if(wxBusinessCircleOrder == null){
return;
}

Integer businessId = EnumBusiness.BUSINESS_ID6.getCode();

if(msg.getMerchantId() != null){
//TODO 第三方获取门店(标识可能发生变化)
WxMerchant wxMerchant = wxMerchantService.getById(msg.getMerchantId());
if(wxMerchant != null){
businessId = wxMerchant.getBusinessId();
}
}


WxCreditHistory creditHistory = new WxCreditHistory();
creditHistory.setTenantId(msg.getFinalTenantId());
creditHistory.setOperatorType(EnumUserType.BUSINESS_CIRCLE.getCode());
creditHistory.setOperatorId(msg.getCUserId());
creditHistory.setCUserId(msg.getCUserId());
creditHistory.setCreateDate(new Date());
creditHistory.setCouponId(msg.getCircleOrderId());
creditHistory.setBusinessId(businessId);
creditHistory.setMerchantId(msg.getMerchantId());

if(EnumYesOrNo.YES.getCode().equals(msg.getIsRefund())){

if(wxBusinessCircleOrder.getIsRefundPoints() == null){
logger.error("积分数据异常------"+ wxBusinessCircleOrder.getId());
return;
}

if(wxBusinessCircleOrder.getIsRefundPoints().equals(EnumYesOrNo.YES.getCode())){
logger.error("积分已退------"+ wxBusinessCircleOrder.getId());
return;
}

creditHistory.setCreditType(EnumScoreType.REFUND_CONSUMPTION.getCode());
creditHistory.setCreditNum(wxBusinessCircleOrder.getIncreasedPoints());

creditHistory.setSpend(0-msg.getAmount());

creditHistory.setChangePurpose("商圈消费退款:商户["+msg.getShopName()+"] ("+creditHistory.getSpendStr()+"元) ");//
creditHistory = creditHistoryService.saveOrUpdate(creditHistory,msg.getTenantId());
Integer creditNum = 0;
if (creditHistory.getCreditNum() != null) {
creditNum = creditHistory.getCreditNum();
}
if(creditNum == 0){
return;
}

wxBusinessCircleOrder.setRefundPointsTime(creditHistory.getCreateDate());
businessCircleOrderService.updateRefundPoints(wxBusinessCircleOrder);

}else if(EnumYesOrNo.NO.getCode().equals(msg.getIsRefund())){

if(wxBusinessCircleOrder.getEarnPoints().equals(EnumYesOrNo.YES.getCode())){
logger.error("已加过积分------"+ wxBusinessCircleOrder.getId());
return;
}

creditHistory.setCreditType(EnumScoreType.CONSUMPTION.getCode());
creditHistory.setSpend(msg.getAmount());
creditHistory.setChangePurpose("商圈消费:消费商户["+msg.getShopName()+"] ("+creditHistory.getSpendStr()+"元) ");
creditHistory = creditHistoryService.saveOrUpdate(creditHistory,msg.getTenantId());
Integer creditNum = 0;
if (creditHistory.getCreditNum() != null) {
creditNum = creditHistory.getCreditNum();
}
if(creditNum == 0){
return;
}

wxBusinessCircleOrder.setIncreasedPoints(creditNum);
wxBusinessCircleOrder.setPointsUpdateTime(creditHistory.getCreateDate());
businessCircleOrderService.updateAddPoints(wxBusinessCircleOrder);

this.notifyPoints(wxBusinessCircleOrder);
}

}

private void notifyPoints(WxBusinessCircleOrder wxBusinessCircleOrder) throws Exception{

if(wxBusinessCircleOrder.getIsPointsNotify().equals(EnumYesOrNo.YES.getCode())){
logger.error("积分已同步------"+ wxBusinessCircleOrder.getId());
return;
}
//添加积分成功,做积分同步
WxPayService wxPayService = wxPayAccountService.getWxPayService(wxBusinessCircleOrder.getTenantId());

PointsNotifyRequest request = new PointsNotifyRequest();
request.setSubMchid(wxPayService.getConfig().getSubMchId());
request.setTransactionId(wxBusinessCircleOrder.getTransactionId());
request.setOpenid(wxBusinessCircleOrder.getOpenid());
request.setEarnPoints(true);
request.setIncreasedPoints(wxBusinessCircleOrder.getIncreasedPoints());
request.setPointsUpdateTime(sdf.format(new Date()));

String result = wxPayService.getBusinessCircleService().notifyPoints(request);
logger.info("微信商圈同步积分请求结果----"+result);

businessCircleOrderService.updateIsPointsNotify(wxBusinessCircleOrder);
}

}

+ 0
- 145
mallinkService/src/main/java/com/iformall/service/msg/impl/FmInsideThirdPartyOrderMsgServiceImpl.java Просмотреть файл

@@ -1,145 +0,0 @@
package com.iformall.service.msg.impl;

import com.github.binarywang.wxpay.bean.businesscircle.PointsNotifyRequest;
import com.github.binarywang.wxpay.service.WxPayService;
import com.iformall.domain.po.*;
import com.iformall.domain.po.msg.BaseMsg;
import com.iformall.domain.po.msg.FmInsideCircleOrderMsg;
import com.iformall.enums.EnumBusiness;
import com.iformall.enums.EnumScoreType;
import com.iformall.enums.EnumUserType;
import com.iformall.enums.EnumYesOrNo;
import com.iformall.service.*;
import com.iformall.service.msg.MsgSendService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

/**
*
*
*/
@Service
public class FmInsideThirdPartyOrderMsgServiceImpl implements MsgSendService {

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
WxMerchantService wxMerchantService;

@Autowired
WxCreditHistoryService creditHistoryService;

@Autowired
WxCUserBasicInfoService cUserBasicInfoService;

@Autowired
WxThirdPartyOrdersService thirdPartyOrdersService;

@Autowired
WxPayAccountService wxPayAccountService;

@Override
public void send(BaseMsg baseMsg) throws Exception {
FmInsideCircleOrderMsg msg = (FmInsideCircleOrderMsg)baseMsg;
logger.info("FmInsideThirdPartyOrderMsgServiceImpl---{}"+msg.toString());
if(msg.getCUserId() == null){
return;
}
WxCUserBasicInfo user = cUserBasicInfoService.getById(msg.getCUserId(), msg.getFinalTenantId());
if(user == null){
return;
}

WxThirdPartyOrders wxThirdPartyOrders = thirdPartyOrdersService.getById(msg.getCircleOrderId(),msg.getTenantId());
if(wxThirdPartyOrders == null){
return;
}

Integer businessId = EnumBusiness.BUSINESS_ID6.getCode();

if(msg.getMerchantId() != null){
//TODO 第三方获取门店(标识可能发生变化)
WxMerchant wxMerchant = wxMerchantService.getById(msg.getMerchantId());
if(wxMerchant != null){
businessId = wxMerchant.getBusinessId();
}
}

WxCreditHistory creditHistory = new WxCreditHistory();
creditHistory.setTenantId(msg.getFinalTenantId());
creditHistory.setOperatorType(EnumUserType.THIRD_CIRCLE.getCode());
creditHistory.setOperatorId(msg.getCUserId());
creditHistory.setCUserId(msg.getCUserId());
creditHistory.setCreateDate(new Date());
creditHistory.setCouponId(msg.getCircleOrderId());
creditHistory.setBusinessId(businessId);
creditHistory.setMerchantId(msg.getMerchantId());

if(EnumYesOrNo.YES.getCode().equals(msg.getIsRefund())){

if(wxThirdPartyOrders.getIsRefundPoints() == null){
logger.error("积分数据异常------"+ wxThirdPartyOrders.getId());
return;
}

if(wxThirdPartyOrders.getIsRefundPoints().equals(EnumYesOrNo.YES.getCode())){
logger.error("积分已退------"+ wxThirdPartyOrders.getId());
return;
}

creditHistory.setCreditType(EnumScoreType.REFUND_CONSUMPTION.getCode());
creditHistory.setCreditNum(wxThirdPartyOrders.getIncreasedPoints());

creditHistory.setSpend(0-msg.getAmount());

creditHistory.setChangePurpose("第三方消费退款:商户["+msg.getShopName()+"] ("+creditHistory.getSpendStr()+"元) ");//
creditHistory = creditHistoryService.saveOrUpdate(creditHistory,msg.getTenantId());
Integer creditNum = 0;
if (creditHistory.getCreditNum() != null) {
creditNum = creditHistory.getCreditNum();
}
if(creditNum == 0){
return;
}

wxThirdPartyOrders.setRefundPointsTime(creditHistory.getCreateDate());
thirdPartyOrdersService.updateRefundPoints(wxThirdPartyOrders);

}else if(EnumYesOrNo.NO.getCode().equals(msg.getIsRefund())){

if(wxThirdPartyOrders.getEarnPoints().equals(EnumYesOrNo.YES.getCode())){
logger.error("已加过积分------"+ wxThirdPartyOrders.getId());
return;
}

creditHistory.setCreditType(EnumScoreType.CONSUMPTION.getCode());
creditHistory.setSpend(msg.getAmount());
creditHistory.setChangePurpose("第三方消费:消费商户["+msg.getShopName()+"] ("+creditHistory.getSpendStr()+"元) ");
creditHistory = creditHistoryService.saveOrUpdate(creditHistory,msg.getTenantId());
Integer creditNum = 0;
if (creditHistory.getCreditNum() != null) {
creditNum = creditHistory.getCreditNum();
}
if(creditNum == 0){
return;
}

wxThirdPartyOrders.setIncreasedPoints(creditNum);
wxThirdPartyOrders.setPointsUpdateTime(creditHistory.getCreateDate());
thirdPartyOrdersService.updateAddPoints(wxThirdPartyOrders);

}

}


}

+ 37
- 49
mallinkService/src/main/resources/mapper/WxBusinessCircleOrderMapper.xml Просмотреть файл

@@ -5,7 +5,6 @@
<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_type" jdbcType="TINYINT" property="sourceType"/>
<result column="notice_id" jdbcType="VARCHAR" property="noticeId" /> <result column="notice_id" jdbcType="VARCHAR" property="noticeId" />
<result column="notice_create_time" jdbcType="TIMESTAMP" property="noticeCreateTime"/> <result column="notice_create_time" jdbcType="TIMESTAMP" property="noticeCreateTime"/>
<result column="notice_event_type" jdbcType="VARCHAR" property="noticeEventType" /> <result column="notice_event_type" jdbcType="VARCHAR" property="noticeEventType" />
@@ -19,6 +18,7 @@
<result column="openid" jdbcType="VARCHAR" property="openid" /> <result column="openid" jdbcType="VARCHAR" property="openid" />
<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="commit_tag" jdbcType="VARCHAR" property="commitTag" /> <result column="commit_tag" jdbcType="VARCHAR" property="commitTag" />


@@ -35,29 +35,18 @@
<result column="is_points_notify" jdbcType="TINYINT" property="isPointsNotify"/> <result column="is_points_notify" jdbcType="TINYINT" property="isPointsNotify"/>


<result column="is_refund" jdbcType="TINYINT" property="isRefund"/> <result column="is_refund" jdbcType="TINYINT" property="isRefund"/>

<result column="refund_notice_id" jdbcType="VARCHAR" property="refundNoticeId" />
<result column="refund_create_time" jdbcType="TIMESTAMP" property="refundCreateTime"/>
<result column="refund_event_type" jdbcType="VARCHAR" property="refundEventType" />
<result column="refund_resource_type" jdbcType="VARCHAR" property="refundResourceType" />
<result column="refund_summary" jdbcType="VARCHAR" property="refundSummary" />
<result column="refund_time" jdbcType="TIMESTAMP" property="refundTime"/>
<result column="refund_amount" jdbcType="INTEGER" property="refundAmount"/>
<result column="refund_id" jdbcType="VARCHAR" property="refundId" /> <result column="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_type`, `notice_id`, `notice_create_time`, `notice_event_type`,
`id`, `tenant_id`, `parent_tenant_id`, `notice_id`, `notice_create_time`, `notice_event_type`,
`notice_resource_type`, `summary`, `wx_mchid`, `wx_merchant_name`, `wx_shop_name`, `wx_shop_number`, `notice_resource_type`, `summary`, `wx_mchid`, `wx_merchant_name`, `wx_shop_name`, `wx_shop_number`,
`appid`, `openid`, `time_end`, `amount`, `transaction_id`, `commit_tag`, `create_time`, `update_time`,
`appid`, `openid`, `time_end`, `amount`, `pay_amount`, `transaction_id`, `commit_tag`, `create_time`, `update_time`,
`merchant_id`, `c_user_id`, `earn_points`, `increased_points`, `points_update_time`, `is_points_notify`, `merchant_id`, `c_user_id`, `earn_points`, `increased_points`, `points_update_time`, `is_points_notify`,
`is_refund`, `refund_notice_id`, `refund_create_time`, `refund_event_type`, `refund_resource_type`,
`refund_summary`, `refund_time`, `refund_amount`, `refund_id`, `is_refund_points`, `refund_points_time`
`is_refund`, `refund_id`, `refund_amount`
</sql> </sql>


<sql id="dynamicWhereConditions"> <sql id="dynamicWhereConditions">
@@ -74,10 +63,6 @@
and `parent_tenant_id` = #{parentTenantId} and `parent_tenant_id` = #{parentTenantId}
</if> </if>


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

<if test=" null != noticeId and '' != noticeId"> <if test=" null != noticeId and '' != noticeId">
and `notice_id` = #{noticeId} and `notice_id` = #{noticeId}
</if> </if>
@@ -137,18 +122,10 @@
and `is_refund` = #{isRefund} and `is_refund` = #{isRefund}
</if> </if>


<if test=" null != refundNoticeId and '' != refundNoticeId">
and `refund_notice_id` = #{refundNoticeId}
</if>

<if test=" null != refundId and '' != refundId"> <if test=" null != refundId and '' != refundId">
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=")">
@@ -173,30 +150,40 @@
and tenant_id=#{tenantId} and tenant_id=#{tenantId}
</select> </select>


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

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


<insert id="insertNoticeOrder" parameterType="com.iformall.domain.po.WxBusinessCircleOrder" > <insert id="insertNoticeOrder" parameterType="com.iformall.domain.po.WxBusinessCircleOrder" >
INSERT INTO wx_business_circle_order ( INSERT INTO wx_business_circle_order (
`id`, `tenant_id`, `parent_tenant_id`, `source_type`, `notice_id`, `notice_create_time`, `notice_event_type`,
`id`, `tenant_id`, `parent_tenant_id`, `notice_id`, `notice_create_time`, `notice_event_type`,
`notice_resource_type`, `summary`, `wx_mchid`, `wx_merchant_name`, `wx_shop_name`, `wx_shop_number`, `notice_resource_type`, `summary`, `wx_mchid`, `wx_merchant_name`, `wx_shop_name`, `wx_shop_number`,
`appid`, `openid`, `time_end`, `amount`, `transaction_id`, `commit_tag`, `create_time`, `update_time`,
`appid`, `openid`, `time_end`, `amount`, `pay_amount`, `transaction_id`, `commit_tag`, `create_time`, `update_time`,
`merchant_id`, `c_user_id`, `earn_points`, `is_points_notify`, `is_refund` `merchant_id`, `c_user_id`, `earn_points`, `is_points_notify`, `is_refund`
) )
VALUES( VALUES(
#{id},#{tenantId},#{parentTenantId},#{sourceType},#{noticeId},#{noticeCreateTime},#{noticeEventType},
#{id},#{tenantId},#{parentTenantId},#{noticeId},#{noticeCreateTime},#{noticeEventType},
#{noticeResourceType},#{summary},#{wxMchid},#{wxMerchantName},#{wxShopName},#{wxShopNumber}, #{noticeResourceType},#{summary},#{wxMchid},#{wxMerchantName},#{wxShopName},#{wxShopNumber},
#{appid},#{openid},#{timeEnd},#{amount},#{transactionId},#{commitTag},#{createTime},#{updateTime},
#{appid},#{openid},#{timeEnd},#{amount},#{payAmount},#{transactionId},#{commitTag},#{createTime},#{updateTime},
#{merchantId},#{cUserId},0,0,0 #{merchantId},#{cUserId},0,0,0
); );
</insert> </insert>


<update id="updateAddPoints" parameterType="com.iformall.domain.po.WxBusinessCircleOrder">
<update id="updatePoints" parameterType="com.iformall.domain.po.WxBusinessCircleOrder">
update wx_business_circle_order set update wx_business_circle_order 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}
@@ -210,18 +197,19 @@
</update> </update>




<update id="updateRefundNoticeOrder" parameterType="com.iformall.domain.po.WxBusinessCircleOrder">
update wx_business_circle_order set
`is_refund` = 1, `refund_notice_id` = #{refundNoticeId}, `refund_create_time` = #{refundCreateTime},
`refund_event_type` = #{refundEventType}, `refund_resource_type` = #{refundResourceType}, `refund_summary` = #{refundSummary},
`refund_time` = #{refundTime}, `refund_amount` = #{refundAmount}, `refund_id` = #{refundId},`update_time` = #{updateTime}
where `id` = #{id} and `tenant_id` = #{tenantId}
</update>

<update id="updateRefundPoints" parameterType="com.iformall.domain.po.WxBusinessCircleOrder">
update wx_business_circle_order set
`is_refund_points` = 1, `refund_points_time` = #{refundPointsTime}, `update_time` = #{updateTime}
where `id` = #{id} and `tenant_id` = #{tenantId}
</update>
<insert id="insertRefundNoticeOrder" parameterType="com.iformall.domain.po.WxBusinessCircleOrder" >
INSERT INTO wx_business_circle_order (
`id`, `tenant_id`, `parent_tenant_id`, `notice_id`, `notice_create_time`, `notice_event_type`,
`notice_resource_type`, `summary`, `wx_mchid`, `wx_merchant_name`, `wx_shop_name`, `wx_shop_number`,
`appid`, `openid`, `time_end`, `amount`,`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},#{wxMchid},#{wxMerchantName},#{wxShopName},#{wxShopNumber},
#{appid},#{openid},#{timeEnd},#{amount},#{payAmount},#{transactionId},#{commitTag},#{createTime},#{updateTime},
#{merchantId},#{cUserId},0,1,#{refundId},#{refundAmount}
);
</insert>


</mapper> </mapper>

Загрузка…
Отмена
Сохранить