袁野 2 months ago
parent 306e4b9a48
commit d6a291d4c4
  1. 109
      bweb/src/main/java/com/bweb/controller/TestController.java
  2. BIN
      cweb/lib/open-platform-sdk-1.0.21.jar
  3. 20
      cweb/pom.xml
  4. 2
      cweb/src/main/java/com/cweb/config/AuthConfig.java
  5. 1
      cweb/src/main/java/com/cweb/controller/cms/CmsContentController.java
  6. 57
      cweb/src/main/java/com/cweb/controller/meituan/MeiTuanController.java
  7. 14
      order/pom.xml
  8. 1
      order/src/main/java/com/order/config/AuthConfig.java
  9. 12
      order/src/main/java/com/order/controller/business/BsOrderGoodsController.java
  10. 58
      order/src/main/java/com/order/controller/business/BsOrderMeiTuanController.java
  11. 104
      order/src/main/java/com/order/controller/notify/MeiTuanController.java
  12. 24
      schedule/src/main/java/com/hfkj/schedule/OrderGoodsSchedule.java
  13. 39
      service/src/main/java/com/hfkj/common/utils/HttpsUtils.java
  14. 10
      service/src/main/java/com/hfkj/common/utils/OrderUtil.java
  15. 88
      service/src/main/java/com/hfkj/meituan/MeiTuanService.java
  16. 10
      service/src/main/java/com/hfkj/service/SecConfigService.java
  17. 1
      service/src/main/java/com/hfkj/service/goods/BsOrderGoodsService.java
  18. 67
      service/src/main/java/com/hfkj/service/goods/BsOrderMeiTuanService.java
  19. 20
      service/src/main/java/com/hfkj/service/goods/impl/BsOrderGoodsServiceImpl.java
  20. 67
      service/src/main/java/com/hfkj/service/goods/impl/BsOrderMeiTuanServiceImpl.java
  21. 17
      service/src/main/java/com/hfkj/service/impl/SecConfigServiceImpl.java
  22. 12
      service/src/main/java/com/hfkj/service/order/BsOrderRefundService.java
  23. 50
      service/src/main/java/com/hfkj/service/order/OrderCreateService.java
  24. 74
      service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java
  25. 101
      service/src/main/java/com/hfkj/service/order/impl/BsOrderRefundServiceImpl.java
  26. 3
      service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java
  27. 1
      service/src/main/java/com/hfkj/sysenum/order/OrderChildProductTypeEnum.java

@ -1,4 +1,5 @@
package com.bweb.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
@ -6,8 +7,15 @@ import com.hfkj.common.exception.SysCode;
import com.hfkj.common.utils.*;
import com.hfkj.config.CommonSysConst;
import com.hfkj.entity.BsOrderGoods;
import com.hfkj.entity.GoodsLogistics;
import com.hfkj.entity.GoodsUserAddress;
import com.hfkj.meituan.MeiTuanService;
import com.hfkj.model.ResponseData;
import com.hfkj.service.goods.BsOrderGoodsService;
import com.hfkj.service.goods.GoodsUserAddressService;
import com.hfkj.sysenum.order.OrderLogisticsStatusEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
@ -17,7 +25,9 @@ import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;
@Controller
@ -25,7 +35,12 @@ import java.util.*;
@Api(value="测试")
public class TestController {
private static Logger log = LoggerFactory.getLogger(TestController.class);
@Resource
private BsOrderGoodsService orderGoodsService;
@Resource
private GoodsUserAddressService addressService;
@Resource
private BsOrderGoodsService bsOrderGoodsService;
@RequestMapping(value="/haiOilLogin",method = RequestMethod.POST)
@ResponseBody
@ -51,4 +66,96 @@ public class TestController {
}
}
@RequestMapping(value="/getLogisticsMsg",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "物流查询")
public ResponseData getLogisticsMsg() {
try {
Map<String , Object> objectMap = new HashMap<>();
objectMap.put("status" , 2);
objectMap.put("createTime" , "createTime");
List<BsOrderGoods> orderGoodsList = orderGoodsService.getList(objectMap);
orderGoodsList = orderGoodsList.stream().filter(order -> order.getLogisticsNo() != null).collect(Collectors.toList());
for (BsOrderGoods goods : orderGoodsList) {
if (goods.getLogisticsNo() != null) {
GoodsLogistics logistics = (GoodsLogistics) bsOrderGoodsService.getLogisticsMsgSchedule(goods.getLogisticsNo() , goods.getUserPhone());
if (logistics.getLogisticsStatus() != null) {
goods.setLogisticsStatus(logistics.getLogisticsStatus());
goods.setLogisticsStatusDesc(logistics.getLogisticsStatusDesc());
} else {
goods.setLogisticsStatus(OrderLogisticsStatusEnum.statusWAIT_ACCEPT.getCode());
goods.setLogisticsStatusDesc(OrderLogisticsStatusEnum.statusWAIT_ACCEPT.getName());
}
goods.setUpdateTime(new Date());
bsOrderGoodsService.update(goods);
}
}
return ResponseMsgUtil.success("map");
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/orderGoodsConfirmReceipt",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "状态更新")
public void orderGoodsConfirmReceipt() {
Map<String , Object> map = new HashMap<>();
map.put("logisticsStatus" , "SIGN");
map.put("status" , 2);
List<BsOrderGoods> orderGoodsList = orderGoodsService.getList(map);
for (BsOrderGoods goods : orderGoodsList) {
// 判断时间是否是十天前
if (DateUtil.differentDays(goods.getCreateTime() , new Date()) > 10) {
orderGoodsService.confirmReceipt(goods.getId());
}
}
}
@RequestMapping(value = "/loginFree", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "H5免登接口")
public ResponseData loginFree(@RequestParam(name = "staffPhone", required = true) String staffPhone,
@RequestParam(name = "productType", required = true) String productType) {
try {
Map<String , Object> map = new HashMap<>();
Map<String , Object> staffInfo = new HashMap<>();
staffInfo.put("staffPhone", staffPhone);
map.put("staffInfo", staffInfo);
map.put("entId", 104310L);
map.put("ts", new Date().getTime());
map.put("productType", productType);
map.put("nonce" , RandomStringGeneratorUtil.generateRandomString(36));
JSONObject jsonObject = MeiTuanService.loginFree(map);
JSONArray jsonArray = jsonObject.getJSONArray("url");
JSONObject json = jsonArray.getJSONObject(0);
return ResponseMsgUtil.success(json.getString("value"));
} catch (Exception e) {
log.error("HighUserCardController --> getHuiLianTongCardConsume() error!", e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -18,6 +18,19 @@
<artifactId>service</artifactId>
<version>PACKT-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.11</version>
</dependency>
<dependency>
<groupId>meituan.skd</groupId>
<artifactId>meituan-open-sdk</artifactId>
<scope>system</scope>
<version>1.0.21</version>
<systemPath>${basedir}/lib/open-platform-sdk-1.0.21.jar</systemPath>
</dependency>
</dependencies>
<build>
@ -26,6 +39,13 @@
<directory>src/main/resources/${env}</directory>
<filtering>false</filtering>
</resource>
<resource>
<directory>${basedir}/lib</directory>
<targetPath>BOOT-INF/lib/</targetPath>
<includes>
<include>**/*.jar</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>

@ -93,7 +93,7 @@ public class AuthConfig implements WebMvcConfigurer {
.excludePathPatterns("/wxMsg/*")
.excludePathPatterns("/cinema/*")
.excludePathPatterns("/starbucks/*")
.excludePathPatterns("/c/*")
.excludePathPatterns("/meiTuan/*")
;
}

@ -39,6 +39,7 @@ public class CmsContentController {
if (platformCode == null) {
platformCode = "WXAPPLETS";
}
map.put("status", 1);
map.put("platformCode", platformCode);
return ResponseMsgUtil.success(cmsContentService.getList(map));

@ -0,0 +1,57 @@
package com.cweb.controller.meituan;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hfkj.common.utils.RandomStringGeneratorUtil;
import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.meituan.MeiTuanService;
import com.hfkj.model.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@Controller
@RequestMapping(value="/meiTuan")
@Api(value="美团")
public class MeiTuanController {
private static final Logger log = LoggerFactory.getLogger(MeiTuanController.class);
@RequestMapping(value = "/loginFree", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "H5免登接口")
public ResponseData loginFree(@RequestParam(name = "staffPhone", required = true) String staffPhone,
@RequestParam(name = "productType", required = true) String productType) {
try {
Map<String , Object> map = new HashMap<>();
Map<String , Object> staffInfo = new HashMap<>();
staffInfo.put("staffPhone", staffPhone);
map.put("staffInfo", staffInfo);
map.put("entId", 104310L);
map.put("ts", new Date().getTime());
map.put("productType", productType);
map.put("nonce" , RandomStringGeneratorUtil.generateRandomString(36));
JSONObject jsonObject = MeiTuanService.loginFree(map);
JSONArray jsonArray = jsonObject.getJSONArray("url");
JSONObject json = jsonArray.getJSONObject(0);
return ResponseMsgUtil.success(json.getString("value"));
} catch (Exception e) {
log.error("HighUserCardController --> getHuiLianTongCardConsume() error!", e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -18,6 +18,13 @@
<artifactId>service</artifactId>
<version>PACKT-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.11</version>
</dependency>
<dependency>
<groupId>meituan.skd</groupId>
<artifactId>meituan-open-sdk</artifactId>
@ -33,6 +40,13 @@
<directory>src/main/resources/${env}</directory>
<filtering>false</filtering>
</resource>
<resource>
<directory>${basedir}/lib</directory>
<targetPath>BOOT-INF/lib/</targetPath>
<includes>
<include>**/*.jar</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>

@ -88,6 +88,7 @@ public class AuthConfig implements WebMvcConfigurer {
.excludePathPatterns("/**/swagger-ui.html")
.excludePathPatterns("/notify/*")
.excludePathPatterns("/cqNotify/*")
.excludePathPatterns("/meiTuan/*")
.excludePathPatterns("/orderCinema/queryOrder")
;
}

@ -90,6 +90,8 @@ public class BsOrderGoodsController {
@RequestParam(value = "merId" , required = false) Long merId,
@RequestParam(value = "createTimeS" , required = false) Long createTimeS,
@RequestParam(value = "createTimeE" , required = false) Long createTimeE,
@RequestParam(value = "finishTimeS" , required = false) Long finishTimeS,
@RequestParam(value = "finishTimeE" , required = false) Long finishTimeE,
@RequestParam(value = "pageNum" , required = true) Integer pageNum,
@RequestParam(value = "pageSize" , required = true) Integer pageSize, HttpServletRequest request) {
try {
@ -120,6 +122,8 @@ public class BsOrderGoodsController {
map.put("payType", payType);
map.put("createTimeS", createTimeS);
map.put("createTimeE", createTimeE);
map.put("finishTimeS", finishTimeS);
map.put("finishTimeE", finishTimeE);
map.put("status", status);
PageHelper.startPage(pageNum, pageSize);
@ -147,6 +151,8 @@ public class BsOrderGoodsController {
@RequestParam(value = "payType" , required = false) Integer payType,
@RequestParam(value = "status" , required = false) Integer status,
@RequestParam(value = "merId" , required = false) Long merId,
@RequestParam(value = "finishTimeS" , required = false) Long finishTimeS,
@RequestParam(value = "finishTimeE" , required = false) Long finishTimeE,
@RequestParam(value = "createTimeS" , required = false) Long createTimeS,
@RequestParam(value = "createTimeE" , required = false) Long createTimeE, HttpServletRequest request) {
// 插入下载记录
@ -184,14 +190,12 @@ public class BsOrderGoodsController {
map.put("payType", payType);
map.put("createTimeS", createTimeS);
map.put("createTimeE", createTimeE);
map.put("finishTimeS", finishTimeS);
map.put("finishTimeE", finishTimeE);
map.put("status", status);
String dataSting = "";
if (createTimeE != null) {
dataSting = DateUtil.date2String(DateUtil.long2Date(createTimeS) , DateUtil.YMDHMS) + "-" + DateUtil.date2String(DateUtil.long2Date(createTimeE) , DateUtil.YMDHMS);
} else {
dataSting = DateUtil.date2String(new Date(), DateUtil.YMDHMS);
}
String fileUrl = CommonSysConst.getSysConfig().getFileUrl();
String filePath = "/temporary/" + userModel.getAccount().getId() + "/" ;

@ -0,0 +1,58 @@
package com.order.controller.business;
import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.entity.SecConfig;
import com.hfkj.model.ResponseData;
import com.hfkj.service.SecConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.math.BigDecimal;
@Controller
@RequestMapping(value="/orderMeiTuan")
@Api(value="美团订单管理")
public class BsOrderMeiTuanController {
@Resource
private SecConfigService secConfigService;
private static final Logger log = LoggerFactory.getLogger(BsOrderGoodsController.class);
@RequestMapping(value="/servicePrice",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询服务费")
public ResponseData servicePrice(@RequestParam(value = "platformCode" , required = true) String platformCode,
@RequestParam(value = "price" , required = true) BigDecimal price
) {
try {
// 查询配置的平台服务费
SecConfig config = secConfigService.queryDetail(platformCode);
BigDecimal servicePrice = new BigDecimal(0);
if (config == null) {
log.error("orderMeiTuan -> servicePrice() error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到相信息");
}
servicePrice = price.multiply(new BigDecimal(config.getCodeValue()));
return ResponseMsgUtil.success(servicePrice);
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -1,14 +1,16 @@
package com.order.controller.notify;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.common.utils.OrderUtil;
import com.hfkj.config.CommonSysConst;
import com.hfkj.entity.BsOrderMeituan;
import com.hfkj.meituan.MeiTuanService;
import com.hfkj.service.goods.BsOrderMeiTuanService;
import com.hfkj.sysenum.order.OrderChildStatusEnum;
import com.meituan.sqt.utils.EncryptUtil;
import com.meituan.sqt.utils.JsonUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
@ -19,9 +21,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;
import javax.annotation.Resource;
import java.util.Date;
import java.util.Objects;
@Controller
@ -29,20 +30,24 @@ import java.util.Objects;
@Api(value = "美团通知")
public class MeiTuanController {
@Resource
private BsOrderMeiTuanService bsOrderMeiTuanService;
private static Logger log = LoggerFactory.getLogger(MeiTuanService.class);
@RequestMapping(value = "/placeOrder", method = RequestMethod.POST)
@ApiOperation(value = "下单")
@ResponseBody
public void placeOrder(@RequestBody JSONObject reqBodyStr, HttpServletRequest request, HttpServletResponse response) {
public Object placeOrder(@RequestBody JSONObject reqBodyStr) {
try {
log.info("============回调任务Start=============");
String accessKey = reqBodyStr.getString("accessKey");
String content = reqBodyStr.getString("content");
log.info("美团下单-回调参数: {}", reqBodyStr);
log.info("美团-回调参数: {}", reqBodyStr);
if (accessKey == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "accessKey错误");
}
if (!Objects.equals(accessKey, CommonSysConst.getSysConfig().getMtAccessKey())) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "accessKey错误");
}
@ -53,19 +58,94 @@ public class MeiTuanController {
JSONObject jsonObject = JSONObject.parseObject(EncryptUtil.aesDecrypt(content, CommonSysConst.getSysConfig().getMtSecretKey()));;
log.info("美团下单-解密参数: {}", jsonObject);
log.info("美团-解密参数: {}", jsonObject);
// 下单
if (Objects.equals(jsonObject.getString("method"), "trade.third.pay")) {
// 创建美团订单
BsOrderMeituan bsOrderMeituan = bsOrderMeiTuanService.findOrderMeiTuanByTradeNo(jsonObject.getString("tradeNo"));
JSONObject data = new JSONObject();
JSONObject object = new JSONObject();
String thirdTradeNo;
if (bsOrderMeituan == null) {
thirdTradeNo = OrderUtil.generateMeiTuanOrderNo();
// 组装数据
BsOrderMeituan orderMeiTuan = new BsOrderMeituan();
orderMeiTuan.setPlatformCode(jsonObject.getString("platformCode"));
orderMeiTuan.setThirdTradeNo(thirdTradeNo);
orderMeiTuan.setCreateTime(new Date());
orderMeiTuan.setUpdateTime(new Date());
orderMeiTuan.setTraceId(jsonObject.getString("traceId"));
orderMeiTuan.setEntId(jsonObject.getLong("entId"));
orderMeiTuan.setTradeNo(jsonObject.getString("tradeNo"));
orderMeiTuan.setSqtBizOrderId(jsonObject.getString("sqtBizOrderId"));
orderMeiTuan.setTradeAmount(jsonObject.getBigDecimal("tradeAmount"));
orderMeiTuan.setEntPayAmount(jsonObject.getBigDecimal("entPayAmount"));
orderMeiTuan.setBusinessDiscountPayAmount(jsonObject.getBigDecimal("businessDiscountPayAmount"));
orderMeiTuan.setServiceFeeAmount(jsonObject.getBigDecimal("serviceFeeAmount"));
orderMeiTuan.setGoodsName(jsonObject.getString("goodsName"));
orderMeiTuan.setTradeExpiringTime(jsonObject.getDate("tradeExpiringTime"));
orderMeiTuan.setNotifyUrl(jsonObject.getString("notifyUrl"));
orderMeiTuan.setReturnUrl(jsonObject.getString("returnUrl"));
orderMeiTuan.setFirstBusinessType(jsonObject.getString("firstBusinessType"));
orderMeiTuan.setSecondBusinessType(jsonObject.getString("secondBusinessType"));
orderMeiTuan.setStaffInfo(jsonObject.getString("staffInfo"));
orderMeiTuan.setStatus(OrderChildStatusEnum.status1.getCode());
bsOrderMeiTuanService.create(orderMeiTuan);
} else {
thirdTradeNo = bsOrderMeituan.getThirdTradeNo();
}
JSONObject staffInfo = jsonObject.getJSONObject("staffInfo");
object.put("thirdTradeNo", thirdTradeNo);
object.put("thirdPayUrl", "https://phgcs.dctpay.com/cweb/#/pages/meiTuanPay/index?tradeNo=" + jsonObject.getString("tradeNo") + "&goodsName=" +
jsonObject.getString("goodsName") +
"&tradeAmount=" + jsonObject.getString("tradeAmount") +
"&outSidePhone=" + staffInfo.getString("staffPhone")
);
log.info("美团下单-参数: {}", object);
data.put("status", 0);
data.put("msg", "成功");
data.put("data", EncryptUtil.aesEncrypt(object.toJSONString() , CommonSysConst.getSysConfig().getMtSecretKey()));
log.info("============回调任务End=============");
return data;
}
// 退款
if (Objects.equals(jsonObject.getString("method"), "trade.third.refund")) {
return null;
}
if (Objects.equals(jsonObject.getString("method"), "trade.third.pay.query")) {
// 美团查询订单
JSONObject object = new JSONObject();
BsOrderMeituan orderMeiTuan = bsOrderMeiTuanService.findOrderMeiTuanByTradeNo(jsonObject.getString("tradeNo"));
object.put("tradeNo" , jsonObject.getString("tradeNo"));
object.put("thirdTradeNo" , orderMeiTuan.getThirdTradeNo());
if (orderMeiTuan.getPayTime() == null) {
object.put("tradeTime" , "1970-01-01 00:00:00");
} else {
object.put("tradeTime" , orderMeiTuan.getPayTime());
response.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=utf-8");
PrintWriter writer= response.getWriter();
writer.write("SUCCESS");
}
object.put("tradeAmount" , orderMeiTuan.getTradeAmount());
object.put("payStatus" , MeiTuanService.payStatus(orderMeiTuan.getStatus()));
log.info("美团查询订单-参数: {}", object);
JSONObject data = new JSONObject();
data.put("status", 0);
data.put("msg", "成功");
data.put("data", EncryptUtil.aesEncrypt(object.toJSONString() , CommonSysConst.getSysConfig().getMtSecretKey()));
log.info("============回调任务End=============");
return data;
}
return null;
} catch (Exception e) {
log.error("WechatPayController --> wechatNotify() error!", e);
return e;
}
}
}

@ -21,6 +21,7 @@ import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @ClassName OrderGoodsSchedule
@ -35,8 +36,7 @@ public class OrderGoodsSchedule {
@Resource
private BsOrderGoodsService orderGoodsService;
@Resource
private BsOrderGoodsService bsOrderGoodsService;
@Resource
private GoodsUserAddressService addressService;
@ -65,7 +65,7 @@ public class OrderGoodsSchedule {
// 判断时间是否是十天前
if (DateUtil.differentDays(goods.getCreateTime() , new Date()) > 10) {
bsOrderGoodsService.confirmReceipt(goods.getId());
orderGoodsService.confirmReceipt(goods.getId());
}
}
}
@ -75,26 +75,20 @@ public class OrderGoodsSchedule {
Map<String , Object> objectMap = new HashMap<>();
objectMap.put("status" , 2);
objectMap.put("createTime" , "createTime");
List<BsOrderGoods> orderGoodsList = orderGoodsService.getList(objectMap);
for (BsOrderGoods goods : orderGoodsList) {
if (goods == null) {
throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "暂无物流信息!");
}
orderGoodsList = orderGoodsList.stream().filter(order -> order.getLogisticsNo() != null).collect(Collectors.toList());
GoodsUserAddress userAddress = addressService.queryDetail(goods.getDeliveryAddressId());
if (userAddress == null) {
throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "暂无物流信息!");
}
for (BsOrderGoods goods : orderGoodsList) {
if (goods.getLogisticsNo() != null) {
GoodsLogistics logistics = (GoodsLogistics) bsOrderGoodsService.getLogisticsMsg(goods.getLogisticsNo() , userAddress.getPhone());
GoodsLogistics logistics = (GoodsLogistics) orderGoodsService.getLogisticsMsgSchedule(goods.getLogisticsNo() , goods.getUserPhone());
if (logistics.getLogisticsStatus() != null) {
goods.setLogisticsStatus(logistics.getLogisticsStatus());
goods.setLogisticsStatusDesc(logistics.getLogisticsStatusDesc());
} else {
goods.setLogisticsStatus(OrderLogisticsStatusEnum.statusWAIT_ACCEPT.getCode());
goods.setLogisticsStatusDesc(OrderLogisticsStatusEnum.statusWAIT_ACCEPT.getName());
@ -102,7 +96,7 @@ public class OrderGoodsSchedule {
goods.setUpdateTime(new Date());
bsOrderGoodsService.update(goods);
orderGoodsService.update(goods);
}
}

@ -365,6 +365,45 @@ public class HttpsUtils {
return null;
}
public static JSONObject doPostMeiTuanUrl(String apiUrl, String str) {
CloseableHttpClient httpClient;
if (apiUrl.startsWith("https")) {
httpClient = HttpClients.custom().setSSLSocketFactory(createSSLConnSocketFactory())
.setConnectionManager(connMgr).setDefaultRequestConfig(requestConfig).build();
} else {
httpClient = HttpClients.createDefault();
}
CloseableHttpResponse response = null;
try {
JSONObject jsonObject = new JSONObject();
HttpPost httpPost = new HttpPost(apiUrl);
httpPost.setConfig(requestConfig);
StringEntity stringEntity = new StringEntity(str, "UTF-8");// 解决中文乱码问题
stringEntity.setContentEncoding("UTF-8");
stringEntity.setContentType("application/json");
httpPost.setEntity(stringEntity);
response = httpClient.execute(httpPost);
if (response.getStatusLine().getStatusCode() == 302) {
jsonObject.put("msg" , true);
jsonObject.put("url" , response.getHeaders("Location"));
}
return jsonObject;
} catch (Exception e) {
log.error(e.getMessage(),e);
} finally {
if (response != null) {
try {
EntityUtils.consume(response.getEntity());
} catch (IOException e) {
log.error(e.getMessage(),e);
}
}
}
return null;
}
public static JSONObject doPostForm(String apiUrl, String body, Map<String,Object> header) {
CloseableHttpClient httpClient = null;

@ -54,6 +54,16 @@ public class OrderUtil {
return IDGenerator.nextId(16);
}
/**
* 生成美团订单号
* @return
* @throws Exception
*/
public static String generateMeiTuanOrderNo() {
// 生成子订单号
return IDGenerator.nextId(11);
}
/**
* 生成退款订单号
* @return

@ -34,9 +34,29 @@ public class MeiTuanService {
*/
public static JSONObject loginFree(Map<String , Object> map) throws Exception {
JSONObject object = request("" , map);
JSONObject object = doPostMeiTuanUrl("https://waimai-openapi.apigw.test.meituan.com/api/sqt/open/login/h5/loginFree/redirection?test_open_swimlane=test-open" , map);
if (object.getBoolean("success") && object.getInteger("code") == 10000) {
if (object.getBoolean("msg")) {
return object;
} else {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "查询失败!");
}
}
/**
* @MethodName paySuccess
* @Description: 支付成功通知接口
* @param map
* @return: com.alibaba.fastjson.JSONObject
* @Author: Sum1Dream
* @Date: 2024/9/18 下午3:42
*/
public static JSONObject paySuccess(Map<String , Object> map , String url) throws Exception {
JSONObject object = request(url , map);
if (object.getBoolean("msg")) {
return object;
} else {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "查询失败!");
@ -53,20 +73,78 @@ public class MeiTuanService {
*/
public static JSONObject request(String postUrl, Map<String,Object> param) throws Exception {
log.info("============ 美团请求-START =============");
param.put("accessKey", CommonSysConst.getSysConfig().getMtAccessKey());
param.put("content", EncryptUtil.aesEncrypt(JsonUtil.object2Json(param), CommonSysConst.getSysConfig().getMtSecretKey()));
log.info("请求接口:" + postUrl);
log.info("请求参数:" + JSONObject.toJSONString(param));
JSONObject response = HttpsUtils.doPost(postUrl, JSONObject.toJSONString(param));
log.info("============ 千猪请求-START =============");
log.info("响应参数:" + response.toJSONString());
log.info("============ 美团请求-END ==============");
return response;
}
/**
* @MethodName doPostMeiTuanUrl
* @Description: 美团免登陆接口
* @param postUrl
* @param param
* @return: com.alibaba.fastjson.JSONObject
* @Author: Sum1Dream
* @Date: 2024/9/18 下午5:44
*/
public static JSONObject doPostMeiTuanUrl(String postUrl, Map<String,Object> param) throws Exception {
log.info("============ 美团请求-START =============");
param.put("accessKey", CommonSysConst.getSysConfig().getMtAccessKey());
param.put("content", EncryptUtil.aesEncrypt(JsonUtil.object2Json(param), CommonSysConst.getSysConfig().getMtSecretKey()));
log.info("请求接口:" + postUrl);
log.info("请求参数:" + JSONObject.toJSONString(param));
JSONObject response = HttpsUtils.doPost(CommonSysConst.getSysConfig().getMtPostUrl() + postUrl, JSONObject.toJSONString(param));
JSONObject response = HttpsUtils.doPostMeiTuanUrl(postUrl, JSONObject.toJSONString(param));
log.info("响应参数:" + response.toJSONString());
log.info("============ 千猪请求-END ==============");
log.info("============ 美团请求-END ==============");
return response;
}
/**
* @MethodName payStatus
* @Description: 美团支付状态转换
* @param payStatus
* @return: java.lang.Integer
* @Author: Sum1Dream
* @Date: 2024/9/18 下午6:03
*/
public static Integer payStatus(Integer payStatus) {
int result;
switch (payStatus) {
case 1:
result = 0;
break;
case 2:
result = 1;
break;
case 3:
result = 1;
break;
case 4:
result = 2;
break;
case 5:
result = 10;
break;
default:
throw new RuntimeException("状态不正确");
}
return result;
}
}

@ -49,4 +49,14 @@ public interface SecConfigService {
* @return com.hfkj.entity.GoodsBrand
*/
SecConfig queryDetail(Integer id);
/**
* @MethodName queryDetail
* @Description:
* @param codeType
* @return: com.hfkj.entity.SecConfig
* @Author: Sum1Dream
* @Date: 2024/9/14 下午3:08
*/
SecConfig queryDetail(String codeType);
}

@ -138,6 +138,7 @@ public interface BsOrderGoodsService {
* @Return com.alibaba.fastjson.JSONObject
*/
Object getLogisticsMsg(String logisticsNo , String mobile);
Object getLogisticsMsgSchedule(String logisticsNo , String mobile);
/**
* @Author Sum1Dream

@ -0,0 +1,67 @@
package com.hfkj.service.goods;
import com.hfkj.entity.BsOrderMeituan;
public interface BsOrderMeiTuanService {
/**
* @MethodName create
* @Description: 创建
* @param orderMeiTuan
* @Author: Sum1Dream
* @Date: 2024/9/5 下午4:18
*/
void create(BsOrderMeituan orderMeiTuan);
/**
* @MethodName update
* @Description: 更新
* @param orderMeiTuan
* @Author: Sum1Dream
* @Date: 2024/9/5 下午4:19
*/
void update(BsOrderMeituan orderMeiTuan);
/**
* @MethodName delete
* @Description: 删除
* @param id
* @param fullDelete
* @Author: Sum1Dream
* @Date: 2024/9/5 下午4:19
*/
void delete(Long id , Boolean fullDelete);
/**
* @MethodName queryDetail
* @Description: 查询详情
* @param id
* @return: com.hfkj.entity.BsOrderMeituan
* @Author: Sum1Dream
* @Date: 2024/9/5 下午4:19
*/
BsOrderMeituan queryDetail(Long id);
/**
* @MethodName findOrderMeiTuan
* @Description: 根据订单号查询
* @param childOrderNo
* @return: com.hfkj.entity.BsOrderMeituan
* @Author: Sum1Dream
* @Date: 2024/9/5 下午4:22
*/
BsOrderMeituan findOrderMeiTuan(String childOrderNo);
/**
* @MethodName findOrderMeiTuanByTradeNo
* @Description: 通过渠道订单号查询
* @param tradeNo
* @return: com.hfkj.entity.BsOrderMeituan
* @Author: Sum1Dream
* @Date: 2024/9/18 下午5:54
*/
BsOrderMeituan findOrderMeiTuanByTradeNo(String tradeNo);
}

@ -174,12 +174,22 @@ public class BsOrderGoodsServiceImpl implements BsOrderGoodsService {
if (MapUtils.getLong(map, "createTimeE") != null) {
criteria.andCreateTimeLessThan(new Date(MapUtils.getLong(map, "createTimeE")));
}
if (MapUtils.getLong(map, "finishTimeS") != null) {
criteria.andFinishTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(map, "finishTimeS")));
}
if (MapUtils.getLong(map, "finishTimeE") != null) {
criteria.andFinishTimeLessThan(new Date(MapUtils.getLong(map, "finishTimeE")));
example.setOrderByClause("finish_time desc");
}
if (MapUtils.getInteger(map, "status") != null) {
criteria.andStatusEqualTo(MapUtils.getInteger(map, "status"));
} else {
criteria.andStatusNotEqualTo(0);
}
if (MapUtils.getString(map , "createTime") == null) {
example.setOrderByClause("create_time desc");
}
return bsOrderGoodsMapper.selectByExample(example);
}
@ -269,7 +279,17 @@ public class BsOrderGoodsServiceImpl implements BsOrderGoodsService {
return editLogistics((JSONObject) jsonObjects.get("data"));
}
@Override
public Object getLogisticsMsgSchedule(String logisticsNo, String mobile) {
JSONObject jsonObjects = OrderUtil.getLogisticsMsg(logisticsNo , mobile);
if (jsonObjects != null) {
if (jsonObjects.getBoolean("success")) {
return editLogistics((JSONObject) jsonObjects.get("data"));
}
}
return null;
}
@Override
public void confirmReceipt(Long orderGoodsId) {

@ -0,0 +1,67 @@
package com.hfkj.service.goods.impl;
import com.hfkj.dao.BsOrderMeituanMapper;
import com.hfkj.entity.BsOrderMeituan;
import com.hfkj.entity.BsOrderMeituanExample;
import com.hfkj.service.goods.BsOrderMeiTuanService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service("bsOrderMeiTuanService")
public class BsOrderMeiTuanServiceImpl implements BsOrderMeiTuanService {
@Resource
private BsOrderMeituanMapper bsOrderMeituanMapper;
@Override
public void create(BsOrderMeituan orderMeiTuan) {
bsOrderMeituanMapper.insert(orderMeiTuan);
}
@Override
public void update(BsOrderMeituan orderMeiTuan) {
bsOrderMeituanMapper.updateByPrimaryKeySelective(orderMeiTuan);
}
@Override
public void delete(Long id, Boolean fullDelete) {
}
@Override
public BsOrderMeituan queryDetail(Long id) {
return null;
}
@Override
public BsOrderMeituan findOrderMeiTuan(String childOrderNo) {
BsOrderMeituanExample example = new BsOrderMeituanExample();
BsOrderMeituanExample.Criteria criteria = example.createCriteria();
criteria.andChildOrderNoEqualTo(childOrderNo);
List<BsOrderMeituan> list = bsOrderMeituanMapper.selectByExample(example);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
@Override
public BsOrderMeituan findOrderMeiTuanByTradeNo(String tradeNo) {
BsOrderMeituanExample example = new BsOrderMeituanExample();
BsOrderMeituanExample.Criteria criteria = example.createCriteria();
criteria.andTradeNoEqualTo(tradeNo);
List<BsOrderMeituan> list = bsOrderMeituanMapper.selectByExample(example);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
}

@ -2,9 +2,11 @@ package com.hfkj.service.impl;
import com.hfkj.dao.SecConfigMapper;
import com.hfkj.entity.SecConfig;
import com.hfkj.entity.SecConfigExample;
import com.hfkj.service.SecConfigService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service("secConfigService")
public class SecConfigServiceImpl implements SecConfigService {
@ -31,4 +33,19 @@ public class SecConfigServiceImpl implements SecConfigService {
public SecConfig queryDetail(Integer id) {
return secConfigMapper.selectByPrimaryKey(id);
}
@Override
public SecConfig queryDetail(String codeType) {
SecConfigExample secConfigExample = new SecConfigExample();
secConfigExample.createCriteria().andCodeTypeEqualTo(codeType);
List<SecConfig> list = secConfigMapper.selectByExample(secConfigExample);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
}

@ -3,6 +3,7 @@ package com.hfkj.service.order;
import com.hfkj.entity.BsOrderRefund;
import com.hfkj.model.order.OrderModel;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
@ -40,6 +41,17 @@ public interface BsOrderRefundService {
*/
BsOrderRefund tradeOrderChildRefund(String childOrderNo, Integer productCount, String remark);
/**
* @MethodName meiTuanRefund
* @Description: 美团退款
* @param childOrderNo
* @param remark
* @return: com.hfkj.entity.BsOrderRefund
* @Author: Sum1Dream
* @Date: 2024/9/18 下午4:33
*/
BsOrderRefund meiTuanRefund(String childOrderNo, String tradeNo , BigDecimal refundPrice, String remark);
/**
* 查询退款
* @param refundOrderNo 退款单号

@ -14,16 +14,19 @@ import com.hfkj.model.order.OrderModel;
import com.hfkj.qianzhu.CinemaService;
import com.hfkj.qianzhu.StarbucksService;
import com.hfkj.service.BsProductConfigService;
import com.hfkj.service.SecConfigService;
import com.hfkj.service.coupon.BsOrderCouponNoService;
import com.hfkj.service.coupon.BsOrderCouponService;
import com.hfkj.service.coupon.channel.HuiLianTongCouponService;
import com.hfkj.service.goods.*;
import com.hfkj.service.hlt.HuiLianTongUnionCardService;
import com.hfkj.service.impl.SecConfigServiceImpl;
import com.hfkj.sysenum.GoodsVpdSourceEnum;
import com.hfkj.sysenum.order.*;
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.Component;
import javax.annotation.Resource;
@ -69,6 +72,10 @@ public class OrderCreateService {
private BsOrderStarbucksService orderStarbucksService;
@Resource
private BsOrderMemberService orderMemberService;
@Resource
private SecConfigService secConfigService;
@Resource
private BsOrderMeiTuanService bsOrderMeiTuanService;
/**
* 事务产品
@ -81,7 +88,7 @@ public class OrderCreateService {
if (goodsMsg == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的商品");
}
if (goodsMsg.getStatus() != 1) {
if (goodsMsg.getStatus() == 0 || goodsMsg.getStatus() == 2 || goodsMsg.getStatus() == 3) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, goodsMsg.getTitle()+"暂无法就进行购买");
}
// 查询商品规格
@ -212,7 +219,7 @@ public class OrderCreateService {
if (goodsMsg == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的商品");
}
if (goodsMsg.getStatus() != 1) {
if (goodsMsg.getStatus() == 0 || goodsMsg.getStatus() == 2 || goodsMsg.getStatus() == 3) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, goodsMsg.getTitle()+"暂无法就进行购买");
}
if (goodsMsg.getType() != 1) {
@ -487,7 +494,7 @@ public class OrderCreateService {
// 星巴克创建订单
// 获取token
Map<String , Object> mapToken = new HashMap<>();
mapToken.put("platformUniqueId" , order.getOrderNo());
mapToken.put("platformUniqueId" , order.getOrderNo() );
mapToken.put("nickname" , order.getUserName());
mapToken.put("mobile" , object.getString("phone"));
StarbucksService.getTokenV2(mapToken);
@ -505,4 +512,41 @@ public class OrderCreateService {
return orderChild;
}
public OrderChildModel meituan(OrderModel order, OrderChildModel orderChild) throws Exception {
// 获取下单业务参数
JSONObject object = new JSONObject((Map<String, Object>) orderChild.getBusiness());
BsProductConfig productConfig = bsProductConfigService.queryDetail(OrderChildProductTypeEnum.type5.getCode());
// 查询配置的平台服务费
SecConfig config = secConfigService.queryDetail(object.getString("platformCode"));
BigDecimal servicePrice = new BigDecimal(0);
if (config != null) {
servicePrice = new BigDecimal(config.getCodeValue());
}
// 查询美团订单
BsOrderMeituan orderMeiTuan = bsOrderMeiTuanService.findOrderMeiTuanByTradeNo(object.getString("tradeNo"));
// 组装数据
orderMeiTuan.setOrderNo(orderChild.getOrderNo());
orderMeiTuan.setChildOrderNo(orderChild.getChildOrderNo());
orderMeiTuan.setMerId(productConfig.getMerId());
orderMeiTuan.setUserId(order.getUserId());
orderMeiTuan.setPlatformCode(object.getString("platformCode"));
orderMeiTuan.setUserPhone(order.getUserPhone());
orderMeiTuan.setServicePrice(orderMeiTuan.getTradeAmount().multiply(servicePrice));
orderMeiTuan.setTotalPrice(orderMeiTuan.getServicePrice().add(orderMeiTuan.getTradeAmount()));
bsOrderMeiTuanService.update(orderMeiTuan);
orderChild.setMerId(productConfig.getMerId());
orderChild.setProductName(orderMeiTuan.getGoodsName());
orderChild.setProductCount(1);
orderChild.setProductImg("202409/1726638258182.png");
orderChild.setProductSpecName(orderMeiTuan.getGoodsName());
orderChild.setProductPrice(orderMeiTuan.getTotalPrice());
return orderChild;
}
}

@ -8,6 +8,7 @@ import com.hfkj.common.exception.SysCode;
import com.hfkj.common.utils.DateUtil;
import com.hfkj.config.CommonSysConst;
import com.hfkj.entity.*;
import com.hfkj.meituan.MeiTuanService;
import com.hfkj.model.order.OrderModel;
import com.hfkj.qianzhu.CinemaService;
import com.hfkj.qianzhu.StarbucksService;
@ -58,8 +59,13 @@ public class OrderPaySuccessService {
private BsOrderStarbucksService orderStarbucksService;
@Resource
private BsOrderCinemaService bsOrderCinemaService;
@Autowired
@Resource
private BsOrderStarbucksServiceImpl bsOrderStarbucksService;
@Resource
private BsOrderMeiTuanService bsOrderMeiTuanService;
@Resource
private BsOrderMemberService bsOrderMemberService;
/**
* 订单业务处理
@ -77,6 +83,8 @@ public class OrderPaySuccessService {
cinema(order, childOrder);
} else if (childOrder.getProductType().equals(OrderChildProductTypeEnum.type4.getCode())) {
starbucks(order , childOrder);
} else if (childOrder.getProductType().equals(OrderChildProductTypeEnum.type5.getCode())) {
meiTuan(order , childOrder);
}
} catch (Exception e) {
@ -106,15 +114,10 @@ public class OrderPaySuccessService {
public void productVpd(OrderModel order, BsOrderChild childOrder) throws Exception {
// 查询卡券订单
BsOrderCoupon orderCoupon = orderCouponService.getDetailByChildOrderNo(childOrder.getChildOrderNo());
// 查询卡券订单的卡密
List<BsOrderCouponNo> couponNoList = orderCouponNoService.getListByCouponOrderId(orderCoupon.getId());
for (BsOrderCouponNo couponNo : couponNoList) {
try {
// 虚拟商品
GoodsVpd vpd = goodsVpdService.queryDetailBySpecsId(childOrder.getProductSpecId());
if (vpd.getSource() == GoodsVpdSourceEnum.type1.getCode()) {
} else if (vpd.getSource() == GoodsVpdSourceEnum.type2.getCode()) {
if (vpd.getSource() == GoodsVpdSourceEnum.type2.getCode()) {
Map<String , Object> map = new HashMap<>();
@ -126,7 +129,28 @@ public class OrderPaySuccessService {
// 推送给娱尚
YuShangService.insertV2(map);
} else if (vpd.getSource() == GoodsVpdSourceEnum.type4.getCode()) {
BsOrderMember orderMember = new BsOrderMember();
orderMember.setTotalPrice(childOrder.getProductTotalPrice());
orderMember.setTotalDeductionPrice(childOrder.getTotalDeductionPrice());
orderMember.setCouponDiscountPrice(childOrder.getCouponDiscountPrice());
orderMember.setIntegralDiscountPrice(childOrder.getIntegralDiscountPrice());
orderMember.setPayRealPrice(childOrder.getSurplusRefundPrice());
orderMember.setPayChannel(order.getPayChannel());
orderMember.setPayType(order.getPayType());
orderMember.setPaySerialNo(order.getPaySerialNo());
orderMember.setPayTime(order.getPayTime());
orderMember.setStatus(OrderChildStatusEnum.status3.getCode());
orderMember.setUpdateTime(new Date());
bsOrderMemberService.update(orderMember);
} else {
// 查询卡券订单的卡密
List<BsOrderCouponNo> couponNoList = orderCouponNoService.getListByCouponOrderId(orderCoupon.getId());
for (BsOrderCouponNo couponNo : couponNoList) {
try {
if (vpd.getSource() == GoodsVpdSourceEnum.type4.getCode()) {
// 推送给汇联通
JSONObject returnParam = HuiLianTongCouponService.costRechargeOrder(couponNo.getChannelOrderNo());
if (returnParam.getString("respCode").equals("0000")) {
@ -196,6 +220,9 @@ public class OrderPaySuccessService {
orderCouponService.editData(orderCoupon);
}
}
}
orderCoupon.setTotalPrice(childOrder.getProductTotalPrice());
orderCoupon.setTotalDeductionPrice(childOrder.getTotalDeductionPrice());
@ -323,5 +350,36 @@ public class OrderPaySuccessService {
}
}
public void meiTuan(OrderModel order,BsOrderChild childOrder) throws Exception {
// 推送订单
// 查询美团订单
BsOrderMeituan orderMeiTuan = bsOrderMeiTuanService.findOrderMeiTuan(childOrder.getChildOrderNo());
if (orderMeiTuan != null) {
Map<String , Object> map = new HashMap<>();
map.put("ts" , new Date().getTime());
map.put("entId" , orderMeiTuan.getEntId());
map.put("tradeNo" , orderMeiTuan.getTradeNo());
map.put("thirdTradeNo" , orderMeiTuan.getThirdTradeNo());
map.put("tradeAmount" , orderMeiTuan.getTradeAmount());
orderMeiTuan.setTotalPrice(childOrder.getProductTotalPrice());
orderMeiTuan.setTotalDeductionPrice(childOrder.getTotalDeductionPrice());
orderMeiTuan.setCouponDiscountPrice(childOrder.getCouponDiscountPrice());
orderMeiTuan.setIntegralDiscountPrice(childOrder.getIntegralDiscountPrice());
orderMeiTuan.setPayRealPrice(childOrder.getSurplusRefundPrice());
orderMeiTuan.setPayChannel(order.getPayChannel());
orderMeiTuan.setPayType(order.getPayType());
orderMeiTuan.setPaySerialNo(order.getPaySerialNo());
orderMeiTuan.setPayTime(order.getPayTime());
orderMeiTuan.setUpdateTime(new Date());
orderMeiTuan.setStatus(OrderChildStatusEnum.status2.getCode());
bsOrderMeiTuanService.update(orderMeiTuan);
MeiTuanService.paySuccess(map , orderMeiTuan.getNotifyUrl());
}
}
}

@ -246,6 +246,107 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService {
}
@Override
@Transactional(propagation= Propagation.REQUIRES_NEW,rollbackFor= {RuntimeException.class})
public BsOrderRefund meiTuanRefund(String childOrderNo, String tradeNo , BigDecimal refundPrice, String remark) {
// 查询子订单
OrderChildModel orderChild = orderChildService.getDetail(childOrderNo);
if (orderChild == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的子订单");
}
// if (productCount > orderChild.getSurplusRefundCount()) {
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "退款失败!退货数量超过子订单可退数量");
// }
// 查询交易订单
BsOrder order = orderService.getOrder(orderChild.getOrderNo());
if (order == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的交易订单");
}
// 创建退款订单
BsOrderRefund orderRefund = new BsOrderRefund();
orderRefund.setMerId(orderChild.getMerId());
orderRefund.setOrderNo(orderChild.getOrderNo());
orderRefund.setOrderChildNo(orderChild.getChildOrderNo());
orderRefund.setUserId(order.getUserId());
orderRefund.setUserPhone(order.getUserPhone());
// 退款订单号 退款标识:R + 时间 + 随机3位数字
orderRefund.setRefundOrderNo("R"+DateUtil.date2String(new Date(), "yyMMddHHmmss") + RandomUtils.number(3, false));
orderRefund.setRefundPayChannel(order.getPayChannel());
orderRefund.setReufndPayType(order.getPayType());
// if (orderChild.getSurplusRefundCount().equals(productCount)) {
// // 全部退款
// orderRefund.setRefundPrice(orderChild.getSurplusRefundPrice());
// orderRefund.setRefundIntegral(orderChild.getSurplusRefundIntegral());
// } else {
// // 部分退款
// // 计算单价
// BigDecimal unitPrice = orderChild.getSurplusRefundPrice().divide(new BigDecimal(orderChild.getProductCount().toString()), 2, BigDecimal.ROUND_DOWN).setScale(2);
// BigDecimal unitPriceIntegral = new BigDecimal(orderChild.getSurplusRefundIntegral().toString()).divide(new BigDecimal("100"))
// .divide(new BigDecimal(orderChild.getProductCount().toString()), 2, BigDecimal.ROUND_DOWN).setScale(2);
//
// orderRefund.setRefundPrice(unitPrice.multiply(new BigDecimal(productCount.toString())));
// orderRefund.setRefundIntegral(unitPriceIntegral.multiply(new BigDecimal("100")).longValue());
// }
if (orderRefund.getRefundIntegral() > 0L) {
Map<String,Object> opUser = new HashMap<>();
opUser.put("opUserType", orderRefund.getOpUserType());
opUser.put("opUserId", orderRefund.getUserId());
opUser.put("opUserPhone", orderRefund.getUserPhone());
Map<String,Object> source = new HashMap<>();
source.put("sourceType", UserIntegralRecordSourceTypeEnum.type2.getCode());
source.put("sourceId", orderChild.getId());
source.put("sourceOrderNo", orderChild.getChildOrderNo());
source.put("sourceContent", "商品订单退款退回积分");
// 退款积分
userIntegralService.entry(orderRefund.getUserId(),orderRefund.getRefundIntegral(), opUser, source);
}
orderRefund.setRefundRemark(remark);
orderRefund.setRefundStatus(OrderRefundStatusEnum.status1.getCode());
orderRefund.setAccountMerchantNo(orderChild.getSettleAccount());
orderRefund.setAccountMerchantKey(orderChild.getSettleAccountKey());
editData(orderRefund);
// 资金退款
orderRefund.setRefundStatus(refundMoney(orderRefund)?OrderRefundStatusEnum.status2.getCode():OrderRefundStatusEnum.status3.getCode());
editData(orderRefund);
// 退款成功
if (orderRefund.getRefundStatus().equals(OrderRefundStatusEnum.status2.getCode())) {
// 修改子订单可退数量、金额、积分
// orderChild.setSurplusRefundCount(orderChild.getSurplusRefundCount() - productCount);
orderChild.setSurplusRefundPrice(orderChild.getSurplusRefundPrice().subtract(orderRefund.getRefundPrice()));
orderChild.setSurplusRefundIntegral(orderChild.getSurplusRefundIntegral() - orderRefund.getRefundIntegral());
orderChild.setStatus(orderChild.getSurplusRefundCount()==0?OrderChildStatusEnum.status4.getCode():orderChild.getStatus());
// 退款业务处理
orderRefundSuccessService.orderRefundHandle(orderChild);
orderChildService.editData(orderChild);
// 查询子订单已全部退款
Map<String,Object> map = new HashMap<>();
map.put("orderNo", orderChild.getOrderNo());
List<BsOrderChild> orderChildList = orderChildService.getList(map);
if (orderChildList.size() == orderChildList.stream().filter(o->o.getStatus().equals(OrderChildStatusEnum.status4.getCode())).collect(Collectors.toList()).size()) {
order.setOrderStatus(OrderStatusEnum.status4.getCode());
order.setRefundTime(new Date());
orderService.editData(order);
}
}
// 删除缓存
orderService.cacheDelete(order.getOrderNo());
return orderRefund;
}
@Override
public BsOrderRefund getRefund(String refundOrderNo) {
BsOrderRefundExample example = new BsOrderRefundExample();

@ -151,6 +151,8 @@ public class BsOrderServiceImpl implements BsOrderService {
child = orderCreateService.cinema(order, child);
}else if (child.getProductType().equals(OrderChildProductTypeEnum.type4.getCode())) {
child = orderCreateService.starbucks(order, child);
}else if (child.getProductType().equals(OrderChildProductTypeEnum.type5.getCode())) {
child = orderCreateService.meituan(order, child);
}
child.setProductTotalPrice(child.getProductPrice().multiply(new BigDecimal(child.getProductCount().toString())));
child.setStatus(OrderChildStatusEnum.status1.getCode());
@ -291,7 +293,6 @@ public class BsOrderServiceImpl implements BsOrderService {
// 订单入库
editData(order);
if (order.getOrderStatus().equals(OrderStatusEnum.status1.getCode())) {
// 10分钟内未支付,自动取消订单
Message<OrderModel> rocketMsg = MessageBuilder.withPayload(order).build();

@ -15,6 +15,7 @@ public enum OrderChildProductTypeEnum {
type2(2, "虚拟产品"),
type3(3, "千猪电影票"),
type4(4, "千猪星巴克"),
type5(5, "美团"),
;
private int code;

Loading…
Cancel
Save