dev-discount
袁野 6 years ago
commit a9cc50fe56
  1. 166
      hai-bweb/src/main/java/com/bweb/controller/ApiMemberProductController.java
  2. 2
      hai-bweb/src/main/java/com/bweb/controller/BsProductConfigController.java
  3. 2
      hai-bweb/src/main/java/com/bweb/controller/HighGoodsTypeController.java
  4. 2
      hai-bweb/src/main/java/com/bweb/controller/HighTestController.java
  5. 2
      hai-cweb/src/main/java/com/cweb/controller/HighTestController.java
  6. 142
      hai-cweb/src/main/java/com/cweb/controller/HighThirdPartyController.java
  7. 52
      hai-cweb/src/main/java/com/cweb/controller/pay/CzOrderController.java
  8. 32
      hai-cweb/src/main/java/com/cweb/controller/pay/UnionPayController.java
  9. 253
      hai-cweb/src/main/java/com/cweb/controller/pay/thirdOrderController.java
  10. 72
      hai-schedule/src/main/java/com/hai/schedule/ApiThirdProductSchedule.java
  11. 223
      hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java
  12. 1
      hai-service/src/main/java/com/hai/common/pay/entity/OrderType.java
  13. 27
      hai-service/src/main/java/com/hai/config/CommonSysConfig.java
  14. 104
      hai-service/src/main/java/com/hai/config/QianZhuConfig.java
  15. 1
      hai-service/src/main/java/com/hai/config/ThirdProductConfig.java
  16. 45
      hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java
  17. 32
      hai-service/src/main/java/com/hai/entity/HighOrder.java
  18. 49
      hai-service/src/main/java/com/hai/enum_type/ApiProductTypeEnum.java
  19. 77
      hai-service/src/main/java/com/hai/model/ThirdPartyModel.java
  20. 57
      hai-service/src/main/java/com/hai/service/ApiMemberProductService.java
  21. 44
      hai-service/src/main/java/com/hai/service/HighOrderService.java
  22. 52
      hai-service/src/main/java/com/hai/service/impl/ApiMemberProductServiceImpl.java
  23. 17
      hai-service/src/main/java/com/hai/service/impl/ApiProductServiceImpl.java
  24. 3
      hai-service/src/main/java/com/hai/service/impl/HighGoodsTypeServiceImpl.java
  25. 675
      hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java
  26. 1
      hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java
  27. 61
      hai-service/src/main/java/com/hai/service/pay/impl/StarbucksOrderServiceImpl.java
  28. 6
      hai-service/src/main/resources/dev/commonConfig.properties
  29. 6
      hai-service/src/main/resources/prod-9401/commonConfig.properties
  30. 4
      hai-service/src/main/resources/prod/commonConfig.properties

@ -0,0 +1,166 @@
package com.bweb.controller;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.common.security.SessionObject;
import com.hai.common.security.UserCenter;
import com.hai.common.utils.*;
import com.hai.entity.ApiMemberProduct;
import com.hai.entity.ApiMerchants;
import com.hai.model.ResponseData;
import com.hai.model.UserInfoModel;
import com.hai.service.ApiMemberProductService;
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.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Controller
@RequestMapping(value = "/apiMemberProduct")
@Api(value = "api商户")
public class ApiMemberProductController {
Logger log = LoggerFactory.getLogger(ApiMemberProductController.class);
@Resource
private ApiMemberProductService apiMemberProductService;
@Autowired
private UserCenter userCenter;
@Resource
private RedisUtil redisUtil;
@RequestMapping(value = "/getListApiMemberProduct", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询产品列表")
public ResponseData getListApiMemberProduct(
@RequestParam(value = "name", required = false) String name,
@RequestParam(value = "typeId", required = false) Integer typeId,
@RequestParam(value = "brandId", required = false) String brandId,
@RequestParam(name = "pageNum", required = true) Integer pageNum,
@RequestParam(name = "pageSize", required = true) Integer pageSize
) {
try {
Map<String, Object> map = new HashMap<>();
map.put("name", name);
map.put("typeId", typeId);
map.put("brandId", brandId);
PageHelper.startPage(pageNum,pageSize);
List<ApiMemberProduct> list = apiMemberProductService.getListApiMemberProduct(map);
return ResponseMsgUtil.success(new PageInfo<>(list));
} catch (Exception e) {
log.error("ApiMerchantsController --> getListUser() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/insertMemberProduct",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "新增产品")
public ResponseData insertMemberProduct(@RequestBody ApiMemberProduct apiMemberProduct, HttpServletRequest request) {
try {
SessionObject sessionObject = userCenter.getSessionObject(request);
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
if (userInfoModel.getBsCompany() == null) {
log.error("HighMerchantController -> updateMerchant() error!","该主角色没有权限");
throw ErrorHelp.genException(SysCode.System, ErrorCode.MENU_TREE_HAS_NOT_ERROR, "");
}
if (StringUtils.isBlank(apiMemberProduct.getName()) ||
apiMemberProduct.getTypeId() == null ||
StringUtils.isBlank(apiMemberProduct.getProductId()) ||
apiMemberProduct.getBrandId() == null ||
apiMemberProduct.getPrice() == null ) {
log.error("ApiMemberProductController -> insertMemberProduct() error!","参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
apiMemberProduct.setCreateTime(new Date());
apiMemberProduct.setUpdateTime(new Date());
apiMemberProduct.setOperatorId(userInfoModel.getSecUser().getId());
apiMemberProduct.setOperatorName(userInfoModel.getSecUser().getUserName());
apiMemberProduct.setStatus(102);
apiMemberProductService.insertApiMemberProduct(apiMemberProduct);
return ResponseMsgUtil.success("新增成功");
} catch (Exception e) {
log.error("ApiMerchantsController -> insertMerchant() error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/updateMemberProduct",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "修改产品")
public ResponseData updateMemberProduct(@RequestBody ApiMemberProduct apiMemberProduct, HttpServletRequest request) {
try {
SessionObject sessionObject = userCenter.getSessionObject(request);
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
if (userInfoModel.getBsCompany() == null) {
log.error("HighMerchantController -> updateMerchant() error!","该主角色没有权限");
throw ErrorHelp.genException(SysCode.System, ErrorCode.MENU_TREE_HAS_NOT_ERROR, "");
}
if (StringUtils.isBlank(apiMemberProduct.getName()) ||
apiMemberProduct.getId() == null ||
apiMemberProduct.getTypeId() == null ||
StringUtils.isBlank(apiMemberProduct.getProductId()) ||
apiMemberProduct.getBrandId() == null ||
apiMemberProduct.getPrice() == null ) {
log.error("ApiMemberProductController -> insertMemberProduct() error!","参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
apiMemberProduct.setUpdateTime(new Date());
apiMemberProduct.setOperatorId(userInfoModel.getSecUser().getId());
apiMemberProduct.setOperatorName(userInfoModel.getSecUser().getUserName());
apiMemberProduct.setStatus(102);
apiMemberProductService.updateApiMemberProduct(apiMemberProduct);
return ResponseMsgUtil.success("修改成功");
} catch (Exception e) {
log.error("ApiMerchantsController -> insertMerchant() error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/findById", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "根据id查询详情")
public ResponseData findById(@RequestParam(value = "id", required = true) Long id) {
try {
return ResponseMsgUtil.success(apiMemberProductService.findById(id));
} catch (Exception e) {
log.error("ApiMerchantsController --> findById() error!", e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -110,7 +110,6 @@ public class BsProductConfigController {
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
if (object == null || if (object == null ||
object.getJSONArray("productIds") == null ||
object.getBigDecimal("discount") == null || object.getBigDecimal("discount") == null ||
object.getInteger("productType") == null || object.getInteger("productType") == null ||
object.getJSONArray("productPlatform") == null || object.getJSONArray("productPlatform") == null ||
@ -146,7 +145,6 @@ public class BsProductConfigController {
if (object == null || if (object == null ||
object.getLong("id") == null || object.getLong("id") == null ||
object.getJSONArray("productIds") == null ||
object.getBigDecimal("discount") == null || object.getBigDecimal("discount") == null ||
object.getInteger("productType") == null || object.getInteger("productType") == null ||
object.getJSONArray("productPlatform") == null || object.getJSONArray("productPlatform") == null ||

@ -52,11 +52,13 @@ public class HighGoodsTypeController {
public ResponseData getListGoodsType(@RequestParam(name = "pageNum", required = true) Integer pageNum, public ResponseData getListGoodsType(@RequestParam(name = "pageNum", required = true) Integer pageNum,
@RequestParam(name = "pageSize", required = true) Integer pageSize, @RequestParam(name = "pageSize", required = true) Integer pageSize,
@RequestParam(name = "title", required = false) String title, @RequestParam(name = "title", required = false) String title,
@RequestParam(name = "userService", required = false) String userService,
HttpServletRequest request) { HttpServletRequest request) {
try { try {
Map<String,String> map = new HashMap<>(); Map<String,String> map = new HashMap<>();
map.put("title", title); map.put("title", title);
map.put("userService", userService);
PageHelper.startPage(pageNum,pageSize); PageHelper.startPage(pageNum,pageSize);
return ResponseMsgUtil.success(new PageInfo<>(highGoodsTypeService.getListGoodsType(map))); return ResponseMsgUtil.success(new PageInfo<>(highGoodsTypeService.getListGoodsType(map)));

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -16,15 +16,13 @@ import com.hai.config.QianZhuConfig;
import com.hai.config.ThirdProductConfig; import com.hai.config.ThirdProductConfig;
import com.hai.entity.*; import com.hai.entity.*;
import com.hai.enum_type.ProductImgEnum; import com.hai.enum_type.ProductImgEnum;
import com.hai.model.ApiStarbucksProductsModel; import com.hai.model.*;
import com.hai.model.BsProductConfigModel;
import com.hai.model.HighUserModel;
import com.hai.model.ResponseData;
import com.hai.service.*; import com.hai.service.*;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.spi.CopyOnWrite;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
@ -66,9 +64,6 @@ public class HighThirdPartyController {
@Autowired @Autowired
private UserCenter userCenter; private UserCenter userCenter;
@Resource
private BsConfigService bsConfigService;
@RequestMapping(value = "/getAllCity", method = RequestMethod.GET) @RequestMapping(value = "/getAllCity", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ -288,8 +283,7 @@ public class HighThirdPartyController {
StringUtils.isBlank(object.getString("regionId")) || StringUtils.isBlank(object.getString("regionId")) ||
StringUtils.isBlank(object.getString("storeCode")) || StringUtils.isBlank(object.getString("storeCode")) ||
object.getInteger("productType") == null || object.getInteger("productType") == null ||
object.getInteger("platformId") == null || object.getInteger("platformId") == null
object.getJSONArray("orderItems") == null
) { ) {
log.error("addOrder error!"); log.error("addOrder error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
@ -310,4 +304,134 @@ public class HighThirdPartyController {
return ResponseMsgUtil.exception(e); return ResponseMsgUtil.exception(e);
} }
} }
@RequestMapping(value = "/getThirdOrderByOrderId", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询第三方订单详情")
public ResponseData getThirdOrderByOrderId(@RequestParam(name = "orderId", required = true) Long orderId) {
try {
HighOrder order = highOrderService.getOrderById(orderId);
JSONObject object;
ThirdPartyModel partyModel = new ThirdPartyModel();
List<Map<String, Object>> list = new ArrayList<>();
// 实际支付金额
BigDecimal orderPayPrice = new BigDecimal(0);
if (order.getHighChildOrderList().get(0).getGoodsType() == 4) {
object = QianZhuConfig.getKfcOrderByOrderNo(order.getOrderNo());
if (object.getBoolean("success")) {
BeanUtils.copyProperties(order, partyModel);
partyModel.setCode(object.getJSONObject("data").getString("ticket"));
partyModel.setThirdOrderStatus(object.getJSONObject("data").getInteger("status"));
if (object.getJSONObject("data").getString("ticket") != null) {
String[] s = object.getJSONObject("data").getString("ticket").split(",");
for (String s1 : s) {
Map<String , Object> map = new HashMap<>();
String[] childString = s1.split("\\|");
map.put("code" , childString[0]);
map.put("phone" , childString[1]);
list.add(map);
}
partyModel.setList(list);
}
partyModel.setEatType(object.getJSONObject("data").getJSONObject("kfcPlaceOrder").getInteger("eatType"));
partyModel.setKfcOrderMobileRemark(object.getJSONObject("data").getString("kfcOrderMobileRemark"));
} else {
log.error("getThirdOrderByOrderId error!", "查询失败!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, object.getString("message"));
}
} else if (order.getHighChildOrderList().get(0).getGoodsType() == 9) {
// 查询详单订单的实际
JSONObject productDetail = thirdProductConfig.getThirdPartyByDetail(1, 1, order.getCompanyId());
object = QianZhuConfig.starbucksOrderByOrderNo(order.getOrderNo());
if (object.getBoolean("success")) {
BeanUtils.copyProperties(order, partyModel);
partyModel.setCode(object.getJSONObject("data").getString("ticket"));
partyModel.setThirdOrderStatus(object.getJSONObject("data").getInteger("status"));
partyModel.setObject(object.getJSONObject("data"));
// 获取星巴克订单内容
JSONArray starbucksOrder = object.getJSONObject("data").getJSONArray("orderItems");
for (Object starbucksObject : starbucksOrder) {
JSONObject childObject = (JSONObject) starbucksObject;
// 计算利润
BigDecimal profitPrice = childObject.getBigDecimal("unitPrice").multiply(productDetail.getBigDecimal("priceDiscount").divide(new BigDecimal(100)));
BigDecimal childPrice = childObject.getBigDecimal("unitPrice").add(profitPrice).setScale(2 , RoundingMode.HALF_UP);
// 计算实际支付金额
orderPayPrice = orderPayPrice.add(childPrice);
childObject.put("unitPrice" , childPrice);
childObject.put("totalPrice" , childPrice.multiply(childObject.getBigDecimal("quantity")));
}
object.getJSONObject("data").put("paymentAmount" , orderPayPrice);
partyModel.setObject(object.getJSONObject("data"));
if (object.getJSONObject("data").getString("code") != null) {
String[] s = object.getJSONObject("data").getString("code").split(",");
for (String s1 : s) {
Map<String , Object> map = new HashMap<>();
String[] childString = s1.split("\\|");
map.put("code" , childString[0]);
map.put("phone" , childString[1]);
list.add(map);
}
partyModel.setList(list);
}
} else {
log.error("getThirdOrderByOrderId error!", "查询失败!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, object.getString("message"));
}
}
return ResponseMsgUtil.success(partyModel);
} catch (Exception e) {
log.error("HighUserCardController --> oilCardRefund() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/thirdCancelOrder", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "取消订单")
public ResponseData thirdCancelOrder(@RequestParam(name = "orderId", required = true) Long orderId) {
try {
HighOrder order = highOrderService.getOrderById(orderId);
if (order.getOrderStatus() == 1) {
highOrderService.thirdCancelOrder(orderId);
} else {
log.error("orderToPay error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.STATUS_ERROR, "");
}
return ResponseMsgUtil.success("操作成功");
} catch (Exception e) {
log.error("HighOrderController --> cancelOrder() error!", e);
return ResponseMsgUtil.exception(e);
}
}
} }

@ -9,6 +9,7 @@ import com.hai.common.exception.SysCode;
import com.hai.common.pay.WechatPayUtil; import com.hai.common.pay.WechatPayUtil;
import com.hai.common.pay.entity.WeChatPayReqInfo; import com.hai.common.pay.entity.WeChatPayReqInfo;
import com.hai.common.pay.util.MD5Util; import com.hai.common.pay.util.MD5Util;
import com.hai.common.security.AESEncodeUtil;
import com.hai.common.security.SessionObject; import com.hai.common.security.SessionObject;
import com.hai.common.security.UserCenter; import com.hai.common.security.UserCenter;
import com.hai.common.utils.*; import com.hai.common.utils.*;
@ -64,6 +65,9 @@ public class CzOrderController {
@Resource @Resource
private UnionPayConfig unionPayConfig; private UnionPayConfig unionPayConfig;
@Resource
private HighUserPayPasswordService highUserPayPasswordService;
@Resource @Resource
private HighUserCardService highUserCardService; private HighUserCardService highUserCardService;
@ -406,19 +410,13 @@ public class CzOrderController {
if (body == null if (body == null
|| body.getLong("orderId") == null || body.getLong("orderId") == null
|| StringUtils.isBlank(body.getString("password"))
|| StringUtils.isBlank(body.getString("cardNo")) || StringUtils.isBlank(body.getString("cardNo"))
) { ) {
log.error("orderToPay error!", "参数错误"); log.error("orderToPay error!", "参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
} }
// 查询用户与卡号的关系
HighUserCard userCard = highUserCardService.getDetailByUserCardNo(userInfoModel.getHighUser().getId(), body.getString("cardNo"));
if (userCard == null) {
log.error("hltUnionCardPay() ERROR", "未绑定卡号");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未绑定卡号");
}
// 订单 // 订单
OutRechargeOrder order = outRechargeOrderService.findByOrderId(body.getLong("orderId")); OutRechargeOrder order = outRechargeOrderService.findByOrderId(body.getLong("orderId"));
@ -433,6 +431,27 @@ public class CzOrderController {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法支付,订单不处于待支付状态"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法支付,订单不处于待支付状态");
} }
// 查询用户支付密码
HighUserPayPassword userPayPassword = highUserPayPasswordService.getDetailByUser(order.getUserId());
if (userPayPassword == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_SET_USER_PAY_PWD, "");
}
if (StringUtils.isBlank(body.getString("password"))) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_ENTER_USER_PAY_PWD, "");
}
// 校验支付密码
if (!AESEncodeUtil.aesEncrypt(body.getString("password")).equals(userPayPassword.getPassword())) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.USER_PAY_PWD_ERROR, "");
}
// 查询用户与卡号的关系
HighUserCard userCard = highUserCardService.getDetailByUserCardNo(userInfoModel.getHighUser().getId(), body.getString("cardNo"));
if (userCard == null) {
log.error("hltUnionCardPay() ERROR", "未绑定卡号");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未绑定卡号");
}
outRechargeOrderService.hltUnionCardPay(userCard, order); outRechargeOrderService.hltUnionCardPay(userCard, order);
return ResponseMsgUtil.success(outRechargeOrderService.findByOrderId(body.getLong("orderId"))); return ResponseMsgUtil.success(outRechargeOrderService.findByOrderId(body.getLong("orderId")));
@ -483,25 +502,6 @@ public class CzOrderController {
} }
} }
@RequestMapping(value="/apiCallBack",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "apiCallBack")
public String test(@RequestBody String reqBodyStr) {
try {
if (StringUtils.isBlank(reqBodyStr)) {
log.error("orderToPay error!", "参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
System.out.println("reqBodyStr");
return "SUCCESS";
} catch (Exception e) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
}
private void apiOrderRecord(OutRechargeOrder rechargeOrder) { private void apiOrderRecord(OutRechargeOrder rechargeOrder) {
Map<String, Object> orderMap = new HashMap<>(); Map<String, Object> orderMap = new HashMap<>();

@ -26,6 +26,7 @@ import com.hai.service.pay.NotifyService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.MapUtils;
import org.apache.commons.io.filefilter.IOFileFilter;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -341,32 +342,15 @@ public class UnionPayController {
} }
} }
} }
if (highChildOrder.getGoodsType() == 4 || highChildOrder.getGoodsType() == 9) {
if (highChildOrder.getGoodsType() == 7) { highChildOrder.setChildOrdeStatus(2);
HighDiscountPackageActual actual = discountPackageActualService.getDetailByChildOrderId(highChildOrder.getId());
if (actual != null) {
List<HighDiscountPackageDiscountActual> discountList = discountPackageDiscountActualService.getHighDiscountPackageDiscountActualList(actual.getId());
for (HighDiscountPackageDiscountActual discount : discountList) {
highDiscountUserRelService.receiveDiscount(order.getMemId(), discount.getAgentDiscountCodeId());
}
HighDiscountPackage discountPackage = discountPackageService.findDiscountPackageById(actual.getDiscountPackageId());
HighDiscountPackageRecord record = new HighDiscountPackageRecord();
record.setDiscountPackageId(discountPackage.getId());
record.setDiscountPackageTitle(discountPackage.getTitle());
record.setUsingAttribution(discountPackage.getUsingAttribution());
record.setCompanyId(discountPackage.getCompanyId());
record.setOrderId(order.getId().intValue());
record.setChildOrderId(highChildOrder.getId().intValue());
record.setRecordNo(System.currentTimeMillis()+"");
record.setSalesType(1);
record.setPrice(order.getPayPrice());
record.setUserId(order.getMemId().intValue());
discountPackageRecordService.insertRecord(record);
actual.setAllocationTime(new Date());
actual.setStatus(3); // 状态: 1: 待分配 2:预分配(售卖)3:已分配
discountPackageActualService.updateHighDiscountPackageActual(actual);
} }
} }
if (order.getHighChildOrderList().get(0).getGoodsType() == 4) {
QianZhuConfig.payKfcOrder(order.getOrderNo());
} else if (order.getHighChildOrderList().get(0).getGoodsType() == 9) {
QianZhuConfig.starbucksOrdersPay(order.getOrderNo());
} }
highOrderService.updateOrder(order); highOrderService.updateOrder(order);

@ -0,0 +1,253 @@
package com.cweb.controller.pay;
import com.alibaba.fastjson.JSONObject;
import com.cweb.config.SysConst;
import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.common.pay.WechatPayUtil;
import com.hai.common.pay.entity.WeChatPayReqInfo;
import com.hai.common.pay.util.MD5Util;
import com.hai.common.security.AESEncodeUtil;
import com.hai.common.security.SessionObject;
import com.hai.common.security.UserCenter;
import com.hai.common.utils.MathUtils;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.config.CommonSysConst;
import com.hai.config.QianZhuConfig;
import com.hai.config.UnionPayConfig;
import com.hai.entity.*;
import com.hai.model.HighUserModel;
import com.hai.model.ResponseData;
import com.hai.service.HighOrderService;
import com.hai.service.HighUserCardService;
import com.hai.service.HighUserPayPasswordService;
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.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
import java.util.SortedMap;
import java.util.concurrent.ThreadLocalRandom;
@Controller
@RequestMapping(value = "/thirdOrder")
@Api(value = "第三方订单支付接口")
public class thirdOrderController {
private static Logger log = LoggerFactory.getLogger(TuanYouController.class);
@Resource
private UserCenter userCenter;
@Resource
private HighOrderService highOrderService;
@Resource
private WechatPayUtil wechatPayUtil;
@Resource
private HighUserCardService highUserCardService;
@Resource
private UnionPayConfig unionPayConfig;
@Resource
private HighUserPayPasswordService highUserPayPasswordService;
@RequestMapping(value="/orderToPayByWx",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "微信订单支付发起支付")
public ResponseData orderToPayByWx(@RequestBody String reqBodyStr) {
try {
if (StringUtils.isBlank(reqBodyStr)) {
log.error("orderToPay error!", "参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
JSONObject jsonObject = JSONObject.parseObject(reqBodyStr);
Long orderId = jsonObject.getLong("orderId");
Integer openIdType = jsonObject.getInteger("openIdType"); // openId类型 1:小程序 2:公众号
String openId = jsonObject.getString("openId"); // openId
if (orderId == null || StringUtils.isBlank(openId)) {
log.error("orderToPay error!", "参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
// 订单
HighOrder order = highOrderService.getOrderById(jsonObject.getLong("orderId"));
if (order == null) {
log.error("orderToPay error!", "未找到订单信息");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单信息");
}
// 订单状态 : 订单支付状态 : 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款
if (order.getOrderStatus() != 1) {
log.error("orderToPayByWx error!", "无法支付,订单不处于待支付状态");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法支付,订单不处于待支付状态");
}
Map<String,Object> map = new HashMap<>();
map.put("orderNo", order.getOrderNo());
map.put("payPrice", order.getPayRealPrice());
if (order.getHighChildOrderList().get(0).getGoodsType() == 4) {
map.put("orderScene", "KFC_ORDER");
} else if (order.getHighChildOrderList().get(0).getGoodsType() == 9) {
map.put("orderScene", "STARBUCKS_ORDER");
}
// 肯德基订单 星巴克订单
map.put("body", "购买第三方产品");
map.put("subject","购买第三方产品");
//微信支付
String nonce_str = MD5Util.MD5Encode(String.valueOf(ThreadLocalRandom.current().nextInt(10000)), "UTF-8");
int total_fee = MathUtils.objectConvertBigDecimal(map.get("payPrice")).multiply(new BigDecimal("100")).intValue();
WeChatPayReqInfo weChatPayReqInfo = new WeChatPayReqInfo();
weChatPayReqInfo.setAppid(SysConst.getSysConfig().getWxMchAppId()); //公众号id
weChatPayReqInfo.setMch_id(SysConst.getSysConfig().getWxMchId()); //商户号
if (openIdType != null && openIdType.equals(2)) {
weChatPayReqInfo.setSub_appid("wxa075e8509802f826"); //商户号公众号
} else {
weChatPayReqInfo.setSub_appid(SysConst.getSysConfig().getWxSubAppId());//小程序
}
weChatPayReqInfo.setSub_mch_id("1614670195");
weChatPayReqInfo.setSub_openid(openId);
weChatPayReqInfo.setNonce_str(nonce_str); //随机字符串
weChatPayReqInfo.setBody(map.get("body").toString()); //商品描述
weChatPayReqInfo.setOut_trade_no(map.get("orderNo").toString()); //商户订单号
weChatPayReqInfo.setTotal_fee(total_fee); //总金额
weChatPayReqInfo.setSpbill_create_ip("139.159.177.244"); //终端ip
weChatPayReqInfo.setNotify_url(SysConst.getSysConfig().getNotifyUrl()); //通知url
weChatPayReqInfo.setTrade_type("JSAPI"); //交易类型
weChatPayReqInfo.setAttach(map.get("orderScene").toString());
weChatPayReqInfo.setProfit_sharing("N");
//附加数据,区分订单类型
Map<String,String> payMap = new HashMap<>();
payMap.put("app_id", weChatPayReqInfo.getSub_appid());
payMap.put("api_key",SysConst.getSysConfig().getWxApiKey());
payMap.put("unified_order_url",SysConst.getSysConfig().getWxUnifiedOrderUrl());
SortedMap<Object, Object> sortedMap = wechatPayUtil.goWechatPay(weChatPayReqInfo,payMap);
return ResponseMsgUtil.success(sortedMap);
} catch (Exception e) {
log.error("orderToPay error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/hltUnionCardPay",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "工会卡支付")
public ResponseData hltUnionCardPay(@RequestBody JSONObject body, HttpServletRequest request) {
try {
// 用户
SessionObject sessionObject = userCenter.getSessionObject(request);
HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject();
if (body == null
|| body.getLong("orderId") == null
|| StringUtils.isBlank(body.getString("password"))
|| StringUtils.isBlank(body.getString("cardNo"))
) {
log.error("orderToPay error!", "参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
// 查询用户与卡号的关系
HighUserCard userCard = highUserCardService.getDetailByUserCardNo(userInfoModel.getHighUser().getId(), body.getString("cardNo"));
if (userCard == null) {
log.error("hltUnionCardPay() ERROR", "未绑定卡号");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未绑定卡号");
}
// 订单
HighOrder order = highOrderService.getOrderById(body.getLong("orderId"));
if (order == null) {
log.error("hltUnionCardPay error!", "未找到订单信息");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单信息");
}
// 订单状态 : 订单支付状态 : 1.待支付 2.已支付 3.已完成 4.已取消 5.已退款
if (order.getOrderStatus() != 1) {
log.error("hltUnionCardPay error!", "无法支付,订单不处于待支付状态");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法支付,订单不处于待支付状态");
}
// 查询用户支付密码
HighUserPayPassword userPayPassword = highUserPayPasswordService.getDetailByUser(order.getMemId());
if (userPayPassword == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_SET_USER_PAY_PWD, "");
}
if (StringUtils.isBlank(body.getString("password"))) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_ENTER_USER_PAY_PWD, "");
}
// 校验支付密码
if (!AESEncodeUtil.aesEncrypt(body.getString("password")).equals(userPayPassword.getPassword())) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.USER_PAY_PWD_ERROR, "");
}
highOrderService.hltUnionCardPayByThirdProduct(userCard, order.getId());
return ResponseMsgUtil.success(order);
} catch (Exception e) {
log.error("hltUnionCardPay error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/orderToUnionPay",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "订单支付发起银联支付")
public ResponseData orderToUnionPay(@RequestBody String reqBodyStr,HttpServletRequest request) {
try {
// 用户
SessionObject sessionObject = userCenter.getSessionObject(request);
HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject();
if (StringUtils.isBlank(reqBodyStr)) {
log.error("orderToPay error!", "参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
JSONObject jsonObject = JSONObject.parseObject(reqBodyStr);
Long orderId = jsonObject.getLong("orderId");
if (orderId == null) {
log.error("orderToPay error!", "参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
// 订单
HighOrder order = highOrderService.getOrderById(orderId);
if (order == null) {
log.error("hltUnionCardPay error!", "未找到订单信息");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单信息");
}
// 订单状态 : 订单支付状态 : 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款
if (order.getOrderStatus() != 1) {
log.error("hltUnionCardPay error!", "无法支付,订单不处于待支付状态");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法支付,订单不处于待支付状态");
}
return ResponseMsgUtil.success(unionPayConfig.upPreOrder(UnionPayConfig.MER_ID2, UnionPayConfig.TERM_ID2, order.getOrderNo(), order.getPayRealPrice(), "购买第三方产品", CommonSysConst.getSysConfig().getUnionPayNotifyUrl(), request));
} catch (Exception e) {
log.error("orderToPay error!", e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -0,0 +1,72 @@
package com.hai.schedule;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hai.config.QianZhuConfig;
import com.hai.entity.ApiStarbucksProducts;
import com.hai.service.ApiProductService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Scheduled;
import javax.annotation.Resource;
import java.util.Date;
@Configuration
public class ApiThirdProductSchedule {
private static final Logger log = LoggerFactory.getLogger(ApiThirdProductSchedule.class);
@Resource
private ApiProductService apiProductService;
@Scheduled(cron = "0 0 1 * * ?") // 获取星巴克产品 每日凌晨1点执行一次
public void getStarbucksProducts() throws Exception {
JSONObject jsonObject = QianZhuConfig.getStarbucksProducts(1 , 200);
JSONObject object = jsonObject.getJSONObject("data");
JSONArray array = object.getJSONArray("items");
for (Object data : array) {
JSONObject dataObject = (JSONObject) data;
ApiStarbucksProducts starbucksProducts = apiProductService.findStarbucksProductsByGoodsId(dataObject.getLong("id"));
if (dataObject.getInteger("shelfStatus") == 5) {
if (starbucksProducts == null) {
starbucksProducts = new ApiStarbucksProducts();
}
starbucksProducts.setCategoryName(dataObject.getString("categoryName"));
starbucksProducts.setCream(dataObject.getString("cream"));
starbucksProducts.setCupSize(dataObject.getString("cupSize"));
starbucksProducts.setDefaultImage(dataObject.getString("defaultImage"));
starbucksProducts.setDes(dataObject.getString("des"));
starbucksProducts.setEspresso(dataObject.getString("espresso"));
starbucksProducts.setMarketGrandePrice(dataObject.getBigDecimal("marketGrandePrice"));
starbucksProducts.setMarketTallPrice(dataObject.getBigDecimal("marketTallPrice"));
starbucksProducts.setMarketVentiPrice(dataObject.getBigDecimal("marketVentiPrice"));
starbucksProducts.setSalesGrandePrice(dataObject.getBigDecimal("salesGrandePrice"));
starbucksProducts.setSalesTallPrice(dataObject.getBigDecimal("salesTallPrice"));
starbucksProducts.setSalesVentiPrice(dataObject.getBigDecimal("salesVentiPrice"));
starbucksProducts.setMilk(dataObject.getString("milk"));
starbucksProducts.setMilkBubble(dataObject.getString("milkBubble"));
starbucksProducts.setName(dataObject.getString("name"));
starbucksProducts.setTemperature(dataObject.getString("temperature"));
if (starbucksProducts.getId() == null) {
starbucksProducts.setCreateTime(new Date());
starbucksProducts.setOperatorId(9999L);
starbucksProducts.setOperatorName("系统生成");
starbucksProducts.setStatus(100);
starbucksProducts.setGoodsId(dataObject.getLong("id"));
apiProductService.insertStarbucksProducts(starbucksProducts);
} else {
starbucksProducts.setUpdateTime(new Date());
apiProductService.updateStarbucksProducts(starbucksProducts);
}
}
}
}
}

@ -63,12 +63,12 @@ public class HighOrderSchedule {
} }
/** /**
* @return void
* @Author Sum1Dream * @Author Sum1Dream
* @name cancelMobileOrder.java * @name cancelMobileOrder.java
* @Description // 取消话费订单 * @Description // 取消话费订单
* @Date 3:33 下午 2021/12/10 * @Date 3:33 下午 2021/12/10
* @Param [] * @Param []
* @return void
*/ */
@Scheduled(cron = "0 0/1 * * * ?") //每15分钟执行一次 @Scheduled(cron = "0 0/1 * * * ?") //每15分钟执行一次
public void cancelMobileOrder() { public void cancelMobileOrder() {
@ -85,12 +85,12 @@ public class HighOrderSchedule {
} }
/** /**
* @return void
* @Author Sum1Dream * @Author Sum1Dream
* @name cancelOrder.java * @name cancelOrder.java
* @Description // 定时发起 * @Description // 定时发起
* @Date 14:18 2022/5/31 * @Date 14:18 2022/5/31
* @Param [] * @Param []
* @return void
*/ */
@Scheduled(cron = "0 0/5 * * * ?") //每10分钟执行一次 @Scheduled(cron = "0 0/5 * * * ?") //每10分钟执行一次
public void initRechargeOrder() { public void initRechargeOrder() {
@ -191,22 +191,27 @@ public class HighOrderSchedule {
} }
/** /**
* @Author 胡锐 * @Author Sum1Dream
* @Description 处理话KFC订单 * @name handleThirdOrder.java
* @Date 2021/4/4 22:45 * @Description // 处理第三方订单
**/ * @Date 16:24 2022/7/8
* @Param []
* @return void
*/
@Scheduled(cron = "0 0/1 * * * ?") //每1分钟执行一次 @Scheduled(cron = "0 0/1 * * * ?") //每1分钟执行一次
public void handleKfcOrder() { public void handleThirdOrder() {
List<HighOrder> orderList = highOrderService.getAlreadyPaidKfcOrder(); List<HighOrder> orderList = highOrderService.getThirdOrder();
// 判断是否存在订单
if (orderList != null && orderList.size() > 0) { if (orderList != null && orderList.size() > 0) {
for (HighOrder order : orderList) { for (HighOrder order : orderList) {
try { try {
HighOrder highOrder = highOrderService.getOrderById(order.getId()); HighOrder highOrder = highOrderService.getOrderById(order.getId());
if (highOrder != null) { if (highOrder != null) {
JSONObject mobileOrderJson = QianZhuConfig.getKfcOrderByOrderNo(highOrder.getOrderNo()); // 肯德基订单
if (mobileOrderJson != null && mobileOrderJson.getBoolean("success") == true) { if (highOrder.getHighChildOrderList().get(0).getGoodsType() == 4) {
JSONObject data = mobileOrderJson.getJSONObject("data"); JSONObject orderObject = QianZhuConfig.getKfcOrderByOrderNo(highOrder.getOrderNo());
if (orderObject != null && orderObject.getBoolean("success")) {
JSONObject data = orderObject.getJSONObject("data");
// 订单状态 0:待付款 5:排队中 15:TRAN_SUCCESS:交易成功 -5:已取消 // 订单状态 0:待付款 5:排队中 15:TRAN_SUCCESS:交易成功 -5:已取消
if (data.getInteger("status") == 15) { if (data.getInteger("status") == 15) {
for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) { for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) {
@ -216,56 +221,23 @@ public class HighOrderSchedule {
highOrder.setFinishTime(new Date()); highOrder.setFinishTime(new Date());
highOrderService.updateOrder(highOrder); highOrderService.updateOrder(highOrder);
} }
// 订单失败
if (data.getInteger("status") == -5) { if (data.getInteger("status") == -5) {
if(highOrder.getPaySerialNo() != null && highOrder.getPayRealPrice() != null) { if (highOrder.getOrderStatus() == 2) {
OrderRefundModel orderRefundModel = WxOrderConfig.orderToRefund(highOrder.getPaySerialNo(), highOrder.getPayRealPrice(), highOrder.getPayRealPrice()); highOrderService.thirdOrderToRefund(order.getId());
if(orderRefundModel.getResult_code().equals("SUCCESS")) {
for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) {
childOrder.setChildOrdeStatus(4);
}
highOrder.setOrderStatus(4);
highOrder.setRefundTime(new Date());
highOrder.setRefundPrice(highOrder.getPayRealPrice());
highOrderService.updateOrder(highOrder);
}
} else { } else {
for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) { highOrderService.thirdCancelOrder(order.getId());
childOrder.setChildOrdeStatus(5);
}
highOrder.setCancelTime(new Date());
highOrder.setOrderStatus(5);
highOrderService.updateOrder(highOrder);
}
}
}
}
} catch (Exception e) {
log.error("HighCouponSchedule --> handleMobileOrder() error!", e);
}
} }
} }
} }
} else if (highOrder.getHighChildOrderList().get(0).getGoodsType() == 9) {
/** // 星巴克订单
* @Author 胡锐 // 根据订单号查询订单详情
* @Description 处理电影票订单 JSONObject orderObject = QianZhuConfig.starbucksOrderByOrderNo(highOrder.getOrderNo());
* @Date 2021/4/4 22:45 if (orderObject != null && orderObject.getBoolean("success")) {
**/ JSONObject data = orderObject.getJSONObject("data");
@Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次 // 订单状态 0:待付款 5:已支付 10:出单中 15:出单成功 20:配送中 25:配送完成 -5:已取消 -10:失败
public void handleCinemaOrder() { if (data.getInteger("status") == 15) {
List<HighOrder> orderList = highOrderService.getAlreadyPaidCinemaOrder();
if (orderList != null && orderList.size() > 0) {
for (HighOrder order : orderList) {
try {
HighOrder highOrder = highOrderService.getOrderById(order.getId());
if (highOrder != null) {
JSONObject mobileOrderJson = QianZhuConfig.getCinemaOrderByOrderNo(highOrder.getOrderNo());
if (mobileOrderJson != null && mobileOrderJson.getBoolean("success") == true) {
JSONObject data = mobileOrderJson.getJSONObject("data");
// 订单状态 0:待付款 5:待出票 10:已出票 15:交易成功 -5:已取消
if (data.getInteger("status") == 10 || data.getInteger("status") == 15) {
for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) { for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) {
childOrder.setChildOrdeStatus(3); childOrder.setChildOrdeStatus(3);
} }
@ -273,37 +245,138 @@ public class HighOrderSchedule {
highOrder.setFinishTime(new Date()); highOrder.setFinishTime(new Date());
highOrderService.updateOrder(highOrder); highOrderService.updateOrder(highOrder);
} }
// 订单失败
if (data.getInteger("status") == -5) { if (data.getInteger("status") == -5) {
if(highOrder.getPaySerialNo() != null && highOrder.getPayRealPrice() != null) { if (highOrder.getOrderStatus() == 2) {
OrderRefundModel orderRefundModel = WxOrderConfig.orderToRefund(highOrder.getPaySerialNo(), highOrder.getPayRealPrice(), highOrder.getPayRealPrice()); highOrderService.thirdOrderToRefund(order.getId());
if(orderRefundModel.getResult_code().equals("SUCCESS")) {
for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) {
childOrder.setChildOrdeStatus(4);
}
highOrder.setOrderStatus(4);
highOrder.setRefundTime(new Date());
highOrder.setRefundPrice(highOrder.getPayRealPrice());
highOrderService.updateOrder(highOrder);
}
} else { } else {
for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) { highOrderService.thirdCancelOrder(order.getId());
childOrder.setChildOrdeStatus(5);
} }
highOrder.setCancelTime(new Date());
highOrder.setOrderStatus(5);
highOrderService.updateOrder(highOrder);
} }
} }
} }
} }
} catch (Exception e) { } catch (Exception e) {
log.error("HighCouponSchedule --> handleMobileOrder() error!", e); log.error("HighOrderSchedule --> handleThirdOrder() error!", e);
} }
} }
} }
} }
// /**
// * @Author 胡锐
// * @Description 处理话KFC订单
// * @Date 2021/4/4 22:45
// **/
// @Scheduled(cron = "0 0/1 * * * ?") //每1分钟执行一次
// public void handleKfcOrder() {
// List<HighOrder> orderList = highOrderService.getAlreadyPaidKfcOrder();
// if (orderList != null && orderList.size() > 0) {
// for (HighOrder order : orderList) {
// try {
// HighOrder highOrder = highOrderService.getOrderById(order.getId());
// if (highOrder != null) {
// JSONObject mobileOrderJson = QianZhuConfig.getKfcOrderByOrderNo(highOrder.getOrderNo());
// if (mobileOrderJson != null && mobileOrderJson.getBoolean("success")) {
// JSONObject data = mobileOrderJson.getJSONObject("data");
//
// // 订单状态 0:待付款 5:排队中 15:TRAN_SUCCESS:交易成功 -5:已取消
// if (data.getInteger("status") == 15) {
// for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) {
// childOrder.setChildOrdeStatus(3);
// }
// highOrder.setOrderStatus(3);
// highOrder.setFinishTime(new Date());
// highOrderService.updateOrder(highOrder);
// }
//
// if (data.getInteger("status") == -5) {
// if (highOrder.getPaySerialNo() != null && highOrder.getPayRealPrice() != null) {
// OrderRefundModel orderRefundModel = WxOrderConfig.orderToRefund(highOrder.getPaySerialNo(), highOrder.getPayRealPrice(), highOrder.getPayRealPrice());
// if (orderRefundModel.getResult_code().equals("SUCCESS")) {
// for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) {
// childOrder.setChildOrdeStatus(4);
// }
// highOrder.setOrderStatus(4);
// highOrder.setRefundTime(new Date());
// highOrder.setRefundPrice(highOrder.getPayRealPrice());
// highOrderService.updateOrder(highOrder);
// }
// } else {
// for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) {
// childOrder.setChildOrdeStatus(5);
// }
// highOrder.setCancelTime(new Date());
// highOrder.setOrderStatus(5);
// highOrderService.updateOrder(highOrder);
// }
// }
// }
// }
// } catch (Exception e) {
// log.error("HighCouponSchedule --> handleMobileOrder() error!", e);
// }
// }
// }
// }
// /**
// * @Author 胡锐
// * @Description 处理电影票订单
// * @Date 2021/4/4 22:45
// **/
// @Scheduled(cron = "0 0/1 * * * ?") //每1分钟执行一次
// public void handleCinemaOrder() {
// List<HighOrder> orderList = highOrderService.getAlreadyPaidCinemaOrder();
// if (orderList != null && orderList.size() > 0) {
// for (HighOrder order : orderList) {
// try {
// HighOrder highOrder = highOrderService.getOrderById(order.getId());
// if (highOrder != null) {
// JSONObject mobileOrderJson = QianZhuConfig.getCinemaOrderByOrderNo(highOrder.getOrderNo());
// if (mobileOrderJson != null && mobileOrderJson.getBoolean("success") == true) {
// JSONObject data = mobileOrderJson.getJSONObject("data");
//
// // 订单状态 0:待付款 5:待出票 10:已出票 15:交易成功 -5:已取消
// if (data.getInteger("status") == 10 || data.getInteger("status") == 15) {
// for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) {
// childOrder.setChildOrdeStatus(3);
// }
// highOrder.setOrderStatus(3);
// highOrder.setFinishTime(new Date());
// highOrderService.updateOrder(highOrder);
// }
//
// if (data.getInteger("status") == -5) {
// if (highOrder.getPaySerialNo() != null && highOrder.getPayRealPrice() != null) {
// OrderRefundModel orderRefundModel = WxOrderConfig.orderToRefund(highOrder.getPaySerialNo(), highOrder.getPayRealPrice(), highOrder.getPayRealPrice());
// if (orderRefundModel.getResult_code().equals("SUCCESS")) {
// for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) {
// childOrder.setChildOrdeStatus(4);
// }
// highOrder.setOrderStatus(4);
// highOrder.setRefundTime(new Date());
// highOrder.setRefundPrice(highOrder.getPayRealPrice());
// highOrderService.updateOrder(highOrder);
// }
// } else {
// for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) {
// childOrder.setChildOrdeStatus(5);
// }
// highOrder.setCancelTime(new Date());
// highOrder.setOrderStatus(5);
// highOrderService.updateOrder(highOrder);
// }
// }
// }
// }
// } catch (Exception e) {
// log.error("HighCouponSchedule --> handleMobileOrder() error!", e);
// }
// }
// }
// }
/** /**
* @Author 胡锐 * @Author 胡锐
* @Description 完成团油订单 超过支付时间24小时订单自动完成 * @Description 完成团油订单 超过支付时间24小时订单自动完成

@ -5,6 +5,7 @@ public enum OrderType {
GOODS_ORDER("GOODS_ORDER", "goodsOrderService", "购买商品"), GOODS_ORDER("GOODS_ORDER", "goodsOrderService", "购买商品"),
RECHARGE_ORDER("RECHARGE_ORDER", "rechargeOrderService", "充值订单"), RECHARGE_ORDER("RECHARGE_ORDER", "rechargeOrderService", "充值订单"),
KFC_ORDER("KFC", "kfcOrderService", "KFC订单"), KFC_ORDER("KFC", "kfcOrderService", "KFC订单"),
STARBUCKS_ORDER("STARBUCKS", "starbucksOrderService", "星巴克订单"),
CINEMA_ORDER("CINEMA", "cinemaOrderService", "电影票订单"), CINEMA_ORDER("CINEMA", "cinemaOrderService", "电影票订单"),
MOBILE_ORDER("MOBILE", "mobileOrderService", "话费充值订单"), MOBILE_ORDER("MOBILE", "mobileOrderService", "话费充值订单"),
TEST("TEST", "testPayService", "支付测试"), TEST("TEST", "testPayService", "支付测试"),

@ -31,6 +31,9 @@ public class CommonSysConfig {
private String qinzhuPlatformId; private String qinzhuPlatformId;
private String qinzhuSecret; private String qinzhuSecret;
private String qianzhuOrderNotify; private String qianzhuOrderNotify;
private String thirdAppKey;
private String thirdAppSecret;
private String thirdPostUrl;
private String huiliantongUrl; private String huiliantongUrl;
private String huiliantongAppNo; private String huiliantongAppNo;
@ -521,4 +524,28 @@ public class CommonSysConfig {
public void setLyNotifyUrl(String lyNotifyUrl) { public void setLyNotifyUrl(String lyNotifyUrl) {
LyNotifyUrl = lyNotifyUrl; LyNotifyUrl = lyNotifyUrl;
} }
public String getThirdAppKey() {
return thirdAppKey;
}
public void setThirdAppKey(String thirdAppKey) {
this.thirdAppKey = thirdAppKey;
}
public String getThirdAppSecret() {
return thirdAppSecret;
}
public void setThirdAppSecret(String thirdAppSecret) {
this.thirdAppSecret = thirdAppSecret;
}
public String getThirdPostUrl() {
return thirdPostUrl;
}
public void setThirdPostUrl(String thirdPostUrl) {
this.thirdPostUrl = thirdPostUrl;
}
} }

@ -132,7 +132,7 @@ public class QianZhuConfig {
map.put("content", JSON.toJSONString(contentMap)); map.put("content", JSON.toJSONString(contentMap));
map.put("traceId", WxUtils.makeNonStr()); map.put("traceId", WxUtils.makeNonStr());
map.put("timestamp", new Date().getTime()); map.put("timestamp", new Date().getTime());
map.put("sign", MD5Util.encode(generateSignature(map,"nnl3gg4ss0pka11t").getBytes()).toLowerCase()); map.put("sign", MD5Util.encode(generateSignature(map,CommonSysConst.getSysConfig().getQinzhuSecret()).getBytes()).toLowerCase());
return HttpsUtils.doPost("https://live.qianzhu8.com/gateway", JSON.toJSONString(map)); return HttpsUtils.doPost("https://live.qianzhu8.com/gateway", JSON.toJSONString(map));
} }
@ -153,7 +153,7 @@ public class QianZhuConfig {
map.put("content", JSON.toJSONString(contentMap)); map.put("content", JSON.toJSONString(contentMap));
map.put("traceId", WxUtils.makeNonStr()); map.put("traceId", WxUtils.makeNonStr());
map.put("timestamp", new Date().getTime()); map.put("timestamp", new Date().getTime());
map.put("sign", MD5Util.encode(generateSignature(map,"nnl3gg4ss0pka11t").getBytes()).toLowerCase()); map.put("sign", MD5Util.encode(generateSignature(map,CommonSysConst.getSysConfig().getQinzhuSecret()).getBytes()).toLowerCase());
return HttpsUtils.doPost("https://nf.qianzhu8.com/gateway", JSON.toJSONString(map)); return HttpsUtils.doPost("https://nf.qianzhu8.com/gateway", JSON.toJSONString(map));
} }
@ -174,7 +174,7 @@ public class QianZhuConfig {
map.put("content", JSON.toJSONString(contentMap)); map.put("content", JSON.toJSONString(contentMap));
map.put("traceId", WxUtils.makeNonStr()); map.put("traceId", WxUtils.makeNonStr());
map.put("timestamp", new Date().getTime()); map.put("timestamp", new Date().getTime());
map.put("sign", MD5Util.encode(generateSignature(map,"nnl3gg4ss0pka11t").getBytes()).toLowerCase()); map.put("sign", MD5Util.encode(generateSignature(map,CommonSysConst.getSysConfig().getQinzhuSecret()).getBytes()).toLowerCase());
return HttpsUtils.doPost("https://nf.qianzhu8.com/gateway", JSON.toJSONString(map)); return HttpsUtils.doPost("https://nf.qianzhu8.com/gateway", JSON.toJSONString(map));
} }
@ -309,7 +309,7 @@ public class QianZhuConfig {
* @Param [java.lang.String, java.lang.String, java.lang.String, java.lang.String] * @Param [java.lang.String, java.lang.String, java.lang.String, java.lang.String]
* @return com.alibaba.fastjson.JSONObject * @return com.alibaba.fastjson.JSONObject
*/ */
public static JSONObject starbucksOrders( Long platformUniqueId ,String storeCode , String orderItems , String customerMobile) throws Exception { public static JSONObject starbucksOrders( String platformUniqueId ,String storeCode , String orderItems , String customerMobile) throws Exception {
Map<String,Object> contentMap = new LinkedHashMap<>(); Map<String,Object> contentMap = new LinkedHashMap<>();
contentMap.put("storeCode", storeCode); contentMap.put("storeCode", storeCode);
@ -319,11 +319,12 @@ public class QianZhuConfig {
Map<String,Object> map = new HashMap<>(); Map<String,Object> map = new HashMap<>();
map.put("platformId", CommonSysConst.getSysConfig().getQinzhuPlatformId()); map.put("platformId", CommonSysConst.getSysConfig().getQinzhuPlatformId());
map.put("action", "starbucksOrders.createOrderV2"); map.put("action", "starbucksOrders.createOrderV2");
map.put("traceId", WxUtils.makeNonStr());
map.put("version", "1.0"); map.put("version", "1.0");
map.put("content", JSON.toJSONString(contentMap)); map.put("content", JSON.toJSONString(contentMap));
map.put("timestamp", new Date().getTime()); map.put("timestamp", new Date().getTime());
map.put("sign", MD5Util.encode(QianZhuConfig.generateSignature(map,CommonSysConst.getSysConfig().getQinzhuSecret()).getBytes()).toLowerCase()); map.put("sign", MD5Util.encode(QianZhuConfig.generateSignature(map,CommonSysConst.getSysConfig().getQinzhuSecret()).getBytes()).toLowerCase());
return HttpsUtils.doPost(CommonSysConst.getSysConfig().getQianzhuH5url()+"/openApi/v1/kfcMenus/listByStoreCode", JSONObject.toJSONString(map)); return HttpsUtils.doPost(CommonSysConst.getSysConfig().getQianzhuH5url(), JSONObject.toJSONString(map));
} }
/** /**
@ -344,7 +345,7 @@ public class QianZhuConfig {
map.put("content", JSON.toJSONString(contentMap)); map.put("content", JSON.toJSONString(contentMap));
map.put("traceId", WxUtils.makeNonStr()); map.put("traceId", WxUtils.makeNonStr());
map.put("timestamp", new Date().getTime()); map.put("timestamp", new Date().getTime());
map.put("sign", MD5Util.encode(generateSignature(map,"nnl3gg4ss0pka11t").getBytes()).toLowerCase()); map.put("sign", MD5Util.encode(generateSignature(map,CommonSysConst.getSysConfig().getQinzhuSecret()).getBytes()).toLowerCase());
return HttpsUtils.doPost(CommonSysConst.getSysConfig().getQianzhuH5url(), JSON.toJSONString(map)); return HttpsUtils.doPost(CommonSysConst.getSysConfig().getQianzhuH5url(), JSON.toJSONString(map));
} }
@ -356,15 +357,16 @@ public class QianZhuConfig {
* @Param [java.lang.String] * @Param [java.lang.String]
* @return com.alibaba.fastjson.JSONObject * @return com.alibaba.fastjson.JSONObject
*/ */
public static JSONObject createKfcOrder(Integer eatType , String storeCode , String mobile , String items , String platformUniqueId , String userRemark) throws Exception { public static JSONObject createKfcOrder(Integer eatType , String storeCode , String mobile , String items , String platformUniqueId) throws Exception {
Map<String,Object> map = new HashMap<>(); Map<String,Object> map = new HashMap<>();
map.put("platformId", CommonSysConst.getSysConfig().getQinzhuPlatformId()); map.put("platformId", CommonSysConst.getSysConfig().getQinzhuPlatformId());
map.put("eatType", eatType); map.put("eatType", eatType);
map.put("storeCode", storeCode); map.put("storeCode", storeCode);
map.put("mobile", mobile); map.put("mobile", mobile);
map.put("userRemark", "");
map.put("subPlatformId", "");
map.put("items", items); map.put("items", items);
map.put("platformUniqueId", platformUniqueId); map.put("platformUniqueId", platformUniqueId);
map.put("userRemark", userRemark);
map.put("timestamp", new Date().getTime()); map.put("timestamp", new Date().getTime());
map.put("sign", MD5Util.encode(QianZhuConfig.generateSignature(map,CommonSysConst.getSysConfig().getQinzhuSecret()).getBytes()).toLowerCase()); map.put("sign", MD5Util.encode(QianZhuConfig.generateSignature(map,CommonSysConst.getSysConfig().getQinzhuSecret()).getBytes()).toLowerCase());
return HttpsUtils.doPost(CommonSysConst.getSysConfig().getQinzhuUrl()+"/openApi/v4/orders/createKfcOrder", JSONObject.toJSONString(map)); return HttpsUtils.doPost(CommonSysConst.getSysConfig().getQinzhuUrl()+"/openApi/v4/orders/createKfcOrder", JSONObject.toJSONString(map));
@ -388,18 +390,94 @@ public class QianZhuConfig {
map.put("content", JSON.toJSONString(contentMap)); map.put("content", JSON.toJSONString(contentMap));
map.put("traceId", WxUtils.makeNonStr()); map.put("traceId", WxUtils.makeNonStr());
map.put("timestamp", new Date().getTime()); map.put("timestamp", new Date().getTime());
map.put("sign", MD5Util.encode(generateSignature(map,"nnl3gg4ss0pka11t").getBytes()).toLowerCase()); map.put("sign", MD5Util.encode(generateSignature(map,CommonSysConst.getSysConfig().getQinzhuSecret()).getBytes()).toLowerCase());
return HttpsUtils.doPost(CommonSysConst.getSysConfig().getQianzhuH5url(), JSON.toJSONString(map)); return HttpsUtils.doPost(CommonSysConst.getSysConfig().getQianzhuH5url(), JSON.toJSONString(map));
} }
public static JSONObject getKfcOrderByOrderNo(Integer eatType , String storeCode , String mobile , String items , String platformUniqueId , String userRemark) throws Exception { /**
* @Author Sum1Dream
* @name getTokenV2.java
* @Description // 联合登录
* @Date 15:07 2022/7/7
* @Param [java.lang.String, java.lang.String, java.lang.String]
* @return com.alibaba.fastjson.JSONObject
*/
public static JSONObject getTokenV2(String platformUniqueId , String nickname , String mobile) throws Exception {
Map<String,Object> contentMap = new LinkedHashMap<>();
contentMap.put("platformUniqueId", platformUniqueId);
contentMap.put("nickname", nickname);
contentMap.put("mobile", mobile);
Map<String,Object> map = new HashMap<>(); Map<String,Object> map = new HashMap<>();
map.put("platformId", CommonSysConst.getSysConfig().getQinzhuPlatformId()); map.put("platformId", CommonSysConst.getSysConfig().getQinzhuPlatformId());
map.put("items", items); map.put("action", "users.getTokenV2");
map.put("version", "1.0");
map.put("content", JSON.toJSONString(contentMap));
map.put("traceId", WxUtils.makeNonStr());
map.put("timestamp", new Date().getTime()); map.put("timestamp", new Date().getTime());
map.put("sign", MD5Util.encode(QianZhuConfig.generateSignature(map,CommonSysConst.getSysConfig().getQinzhuSecret()).getBytes()).toLowerCase()); map.put("sign", MD5Util.encode(generateSignature(map,CommonSysConst.getSysConfig().getQinzhuSecret()).getBytes()).toLowerCase());
return HttpsUtils.doPost(CommonSysConst.getSysConfig().getQinzhuUrl()+"/openApi/v4/orders/createKfcOrder", JSONObject.toJSONString(map)); return HttpsUtils.doPost("https://live-test.qianzhu8.com/gateway", JSON.toJSONString(map));
} }
/**
* @Author Sum1Dream
* @name insertV2.java
* @Description // 第三方充值下单
* @Date 17:38 2022/7/8
* @Param [java.lang.String, java.lang.Integer, java.lang.String, java.lang.String]
* @return com.alibaba.fastjson.JSONObject
*/
public static JSONObject insertV2(String productCode , String orderNo , String chargeAccount) throws Exception {
Map<String,Object> map = new HashMap<>();
map.put("AppKey", CommonSysConst.getSysConfig().getThirdAppKey());
map.put("TimesTamp", new Date().getTime());
map.put("ProductCode", productCode);
map.put("BuyCount", 1);
map.put("MOrderID", orderNo);
map.put("ChargeAccount", chargeAccount);
map.put("CustomerIP", "127.0.0.1");
map.put("sign", MD5Util.encode(generateSignatureByThird(map,CommonSysConst.getSysConfig().getThirdAppSecret()).getBytes()));
return HttpsUtils.doPost(CommonSysConst.getSysConfig().getThirdPostUrl() + "Order/InsertV2", JSON.toJSONString(map));
}
/**
* @Author Sum1Dream
* @name QueryV2.java
* @Description // 查询第三方订单详情
* @Date 17:37 2022/7/8
* @Param [java.lang.String]
* @return com.alibaba.fastjson.JSONObject
*/
public static JSONObject QueryV2(String orderNo) throws Exception {
Map<String,Object> map = new HashMap<>();
map.put("AppKey", CommonSysConst.getSysConfig().getThirdAppKey());
map.put("TimesTamp", new Date().getTime());
map.put("MOrderID", orderNo);
map.put("OrderID", "");
String sb = CommonSysConst.getSysConfig().getThirdAppKey() + new Date().getTime() + orderNo + CommonSysConst.getSysConfig().getThirdAppSecret();
map.put("sign", MD5Util.encode(sb.getBytes()));
return HttpsUtils.doPost(CommonSysConst.getSysConfig().getThirdPostUrl() + "Order/QueryV2", map);
}
/**
* 生成签名
* @param data 数据
* @param key 秘钥app_secret
* @return 加密结果
*/
public static String generateSignatureByThird(final Map<String, Object> data, String key){
Set<String> keySet = data.keySet();
String[] keyArray = keySet.toArray(new String[keySet.size()]);
Arrays.sort(keyArray);
StringBuilder sb = new StringBuilder();
for (String k : keyArray) {
if (k.equals(WXPayConstants.FIELD_SIGN)) {
continue;
}
sb.append(data.get(k));
}
sb.append(key);
return sb.toString();
}
} }

@ -71,6 +71,7 @@ public class ThirdProductConfig {
listMap.put("platformId", platformId); listMap.put("platformId", platformId);
object.put("integralDiscount" , bsConfigService.getProductDiscountByMap(listMap).getDiscount()); object.put("integralDiscount" , bsConfigService.getProductDiscountByMap(listMap).getDiscount());
object.put("priceDiscount" , productConfig.getDiscount());
object.put("productPayType" , bsConfigService.getProductPayTypeByMap(listMap)); object.put("productPayType" , bsConfigService.getProductPayTypeByMap(listMap));
object.put("productPlatform" , bsConfigService.getProductPlatformByMap(listMap)); object.put("productPlatform" , bsConfigService.getProductPlatformByMap(listMap));

@ -42,6 +42,51 @@ public interface HighOrderMapperExt {
}) })
List<HighOrder> getCloseOrder(); List<HighOrder> getCloseOrder();
@Select({"select distinct * from high_order a left join high_child_order b on a.id = b.order_id where order_status in (1,2) and goods_type in (4,9) group by a.id;"})
@Results({
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
@Result(column="order_no", property="orderNo", jdbcType=JdbcType.VARCHAR),
@Result(column="mem_discount_id", property="memDiscountId", jdbcType=JdbcType.BIGINT),
@Result(column="mem_discount_name", property="memDiscountName", jdbcType=JdbcType.VARCHAR),
@Result(column="mem_id", property="memId", jdbcType=JdbcType.BIGINT),
@Result(column="mem_name", property="memName", jdbcType=JdbcType.VARCHAR),
@Result(column="mem_phone", property="memPhone", jdbcType=JdbcType.VARCHAR),
@Result(column="mem_card_id", property="memCardId", jdbcType=JdbcType.BIGINT),
@Result(column="mem_card_type", property="memCardType", jdbcType=JdbcType.INTEGER),
@Result(column="mem_card_no", property="memCardNo", jdbcType=JdbcType.VARCHAR),
@Result(column="pay_model", property="payModel", jdbcType=JdbcType.INTEGER),
@Result(column="pay_type", property="payType", jdbcType=JdbcType.INTEGER),
@Result(column="pay_gold", property="payGold", jdbcType=JdbcType.INTEGER),
@Result(column="pay_price", property="payPrice", jdbcType=JdbcType.DECIMAL),
@Result(column="pay_real_price", property="payRealPrice", jdbcType=JdbcType.DECIMAL),
@Result(column="pay_serial_no", property="paySerialNo", jdbcType=JdbcType.VARCHAR),
@Result(column="deduction_price", property="deductionPrice", jdbcType=JdbcType.DECIMAL),
@Result(column="order_status", property="orderStatus", jdbcType=JdbcType.INTEGER),
@Result(column="total_price", property="totalPrice", jdbcType=JdbcType.DECIMAL),
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="pay_time", property="payTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="cancel_time", property="cancelTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="cancel_remarks", property="cancelRemarks", jdbcType=JdbcType.VARCHAR),
@Result(column="finish_time", property="finishTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="remarks", property="remarks", jdbcType=JdbcType.VARCHAR),
@Result(column="refund_time", property="refundTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="refund_price", property="refundPrice", jdbcType=JdbcType.DECIMAL),
@Result(column="refund_content", property="refundContent", jdbcType=JdbcType.VARCHAR),
@Result(column="refusal_refund_content", property="refusalRefundContent", jdbcType=JdbcType.VARCHAR),
@Result(column="Identification_code", property="identificationCode", jdbcType=JdbcType.BIGINT),
@Result(column="profit_sharing_status", property="profitSharingStatus", jdbcType=JdbcType.BIT),
@Result(column="profit_sharing_ratio", property="profitSharingRatio", jdbcType=JdbcType.DECIMAL),
@Result(column="account_merchant_num", property="accountMerchantNum", jdbcType=JdbcType.VARCHAR),
@Result(column="print_status", property="printStatus", jdbcType=JdbcType.BIT),
@Result(column="print_num", property="printNum", jdbcType=JdbcType.INTEGER),
@Result(column="region_id", property="regionId", jdbcType=JdbcType.VARCHAR),
@Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR),
@Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR),
@Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR)
})
List<HighOrder> getThirdOrder();
@Select({ @Select({
"<script>", "<script>",
"select", "select",

@ -3,6 +3,7 @@ package com.hai.entity;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.List;
/** /**
* high_order * high_order
@ -217,6 +218,37 @@ public class HighOrder implements Serializable {
private String ext3; private String ext3;
private List<HighChildOrder> highChildOrderList;
private HighDiscount highDiscount;
private Boolean isTyAgent;
public List<HighChildOrder> getHighChildOrderList() {
return highChildOrderList;
}
public void setHighChildOrderList(List<HighChildOrder> highChildOrderList) {
this.highChildOrderList = highChildOrderList;
}
public HighDiscount getHighDiscount() {
return highDiscount;
}
public void setHighDiscount(HighDiscount highDiscount) {
this.highDiscount = highDiscount;
}
public Boolean getIsTyAgent() {
return isTyAgent;
}
public void setIsTyAgent(Boolean tyAgent) {
isTyAgent = tyAgent;
}
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public Long getId() { public Long getId() {

@ -0,0 +1,49 @@
package com.hai.enum_type;
import java.util.Objects;
/**
* @serviceName ApiProductTypeEnum.java
* @author Sum1Dream
* @version 1.0.0
* @Description // 产品类型
* @createTime 17:06 2022/7/8
**/
public enum ApiProductTypeEnum {
type1(1, "星巴克"),
type2(2, "肯德基"),
type3(3, "第三方产品")
;
private Integer type;
private String name;
ApiProductTypeEnum(int type, String name) {
this.type = type;
this.name = name;
}
public static String getNameByType(Integer type) {
for (ApiProductTypeEnum ele : values()) {
if(Objects.equals(type,ele.getType())) return ele.getName();
}
return null;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

@ -0,0 +1,77 @@
package com.hai.model;
import com.alibaba.fastjson.JSONObject;
import com.hai.entity.HighOrder;
import java.util.List;
import java.util.Map;
public class ThirdPartyModel extends HighOrder {
// 取餐码
private String code;
// 第三方订单状态
private Integer thirdOrderStatus;
// 就餐方式
private Integer eatType;
// 下单手机备注
private String kfcOrderMobileRemark;
// 取餐码
private List<Map<String, Object>> list;
// 第三方内容
private JSONObject object;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public Integer getThirdOrderStatus() {
return thirdOrderStatus;
}
public void setThirdOrderStatus(Integer thirdOrderStatus) {
this.thirdOrderStatus = thirdOrderStatus;
}
public Integer getEatType() {
return eatType;
}
public void setEatType(Integer eatType) {
this.eatType = eatType;
}
public String getKfcOrderMobileRemark() {
return kfcOrderMobileRemark;
}
public void setKfcOrderMobileRemark(String kfcOrderMobileRemark) {
this.kfcOrderMobileRemark = kfcOrderMobileRemark;
}
public List<Map<String, Object>> getList() {
return list;
}
public void setList(List<Map<String, Object>> list) {
this.list = list;
}
public JSONObject getObject() {
return object;
}
public void setObject(JSONObject object) {
this.object = object;
}
}

@ -0,0 +1,57 @@
package com.hai.service;
import com.hai.entity.ApiMemberProduct;
import java.util.List;
import java.util.Map;
/**
* @serviceName ApiMemberProductService.java
* @author Sum1Dream
* @version 1.0.0
* @Description // 会员产品接口
* @createTime 16:12 2022/7/11
**/
public interface ApiMemberProductService {
/**
* @Author Sum1Dream
* @name insertApiMemberProduct.java
* @Description // 新增会员产品
* @Date 14:55 2022/6/7
* @Param [com.alibaba.fastjson.JSONObject]
* @return void
*/
void insertApiMemberProduct(ApiMemberProduct ApiMemberProduct);
/**
* @Author Sum1Dream
* @name updateApiMemberProduct.java
* @Description // 修改会员产品
* @Date 14:56 2022/6/7
* @Param [com.alibaba.fastjson.JSONObject]
* @return void
*/
void updateApiMemberProduct(ApiMemberProduct ApiMemberProduct);
/**
* @Author Sum1Dream
* @name getListApiMemberProduct.java
* @Description // 查询会员产品
* @Date 14:57 2022/6/7
* @Param [java.util.Map<java.lang.String,java.lang.Object>]
* @return java.util.List<com.hai.entity.ApiMemberProduct>
*/
List<ApiMemberProduct> getListApiMemberProduct(Map<String, Object> map);
/**
* @Author Sum1Dream
* @name findById.java
* @Description // 根据id 查询会员产品
* @Date 15:24 2022/6/7
* @Param [java.lang.Long]
* @return com.hai.entity.ApiMemberProduct
*/
ApiMemberProduct findById(Long id);
}

@ -3,6 +3,8 @@ package com.hai.service;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.hai.entity.HighChildOrder; import com.hai.entity.HighChildOrder;
import com.hai.entity.HighOrder; import com.hai.entity.HighOrder;
import com.hai.entity.HighUserCard;
import com.hai.entity.OutRechargeOrder;
import com.hai.model.*; import com.hai.model.*;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -443,5 +445,45 @@ public interface HighOrderService {
* @Param [com.alibaba.fastjson.JSONObject] * @Param [com.alibaba.fastjson.JSONObject]
* @return void * @return void
*/ */
JSONObject insertThirdProduct(JSONObject object) throws Exception; HighOrder insertThirdProduct(JSONObject object) throws Exception;
/**
* @Author Sum1Dream
* @name hltUnionCardPay.java
* @Description // 汇联通支付
* @Date 17:21 2022/5/25
* @Param [java.lang.Long, com.hai.entity.OutRechargeOrder]
* @return void
*/
void hltUnionCardPayByThirdProduct(HighUserCard userCard, Long orderId) throws Exception;
/**
* @Author Sum1Dream
* @name getThirdOrder.java
* @Description // 查询第三方为支付已支付订单
* @Date 11:26 2022/7/8
* @Param []
* @return java.util.List<com.hai.entity.HighOrder>
*/
List<HighOrder> getThirdOrder();
/**
* @Author Sum1Dream
* @name orderToRefund.java
* @Description // 第三方订单退款
* @Date 4:44 下午 2022/1/24
* @Param [java.lang.Long]
* @return void
*/
void thirdOrderToRefund(Long orderId) throws Exception;
/**
* @Author Sum1Dream
* @Description //取消订单 Administrator
* @Date 18:37 2021/6/12
* @Param [orderId]
* @return void
**/
void thirdCancelOrder(Long orderId);
} }

@ -0,0 +1,52 @@
package com.hai.service.impl;
import com.hai.dao.ApiMemberProductMapper;
import com.hai.entity.ApiMemberProduct;
import com.hai.entity.ApiMemberProductExample;
import com.hai.service.ApiMemberProductService;
import org.apache.commons.collections4.MapUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
@Service("apiMemberProductService")
public class ApiMemberProductServiceImpl implements ApiMemberProductService {
@Resource
private ApiMemberProductMapper apiMemberProductMapper;
@Override
public void insertApiMemberProduct(ApiMemberProduct apiMemberProduct) {
apiMemberProductMapper.insert(apiMemberProduct);
}
@Override
public void updateApiMemberProduct(ApiMemberProduct apiMemberProduct) {
apiMemberProductMapper.updateByPrimaryKeySelective(apiMemberProduct);
}
@Override
public List<ApiMemberProduct> getListApiMemberProduct(Map<String, Object> map) {
ApiMemberProductExample example = new ApiMemberProductExample();
ApiMemberProductExample.Criteria criteria = example.createCriteria();
if (MapUtils.getInteger(map , "typeId") != null) {
criteria.andTypeIdEqualTo(MapUtils.getInteger(map , "typeId"));
}
if (MapUtils.getInteger(map , "brandId") != null) {
criteria.andBrandIdEqualTo(MapUtils.getInteger(map , "brandId"));
}
if (MapUtils.getString(map , "name") != null) {
criteria.andNameLike("%" + MapUtils.getString(map , "name") + "%");
}
example.setOrderByClause("brand_id ASC , sort ASC");
return apiMemberProductMapper.selectByExample(example);
}
@Override
public ApiMemberProduct findById(Long id) {
return apiMemberProductMapper.selectByPrimaryKey(id);
}
}

@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import com.hai.common.security.UserCenter; import com.hai.common.security.UserCenter;
import com.hai.dao.*; import com.hai.dao.*;
import com.hai.entity.*; import com.hai.entity.*;
import com.hai.enum_type.ApiProductTypeEnum;
import com.hai.model.BsProductConfigModel; import com.hai.model.BsProductConfigModel;
import com.hai.model.UserInfoModel; import com.hai.model.UserInfoModel;
import com.hai.service.ApiProductService; import com.hai.service.ApiProductService;
@ -205,15 +206,10 @@ public class ApiProductServiceImpl implements ApiProductService {
@Override @Override
@Transactional(propagation = Propagation.REQUIRES_NEW) @Transactional(propagation = Propagation.REQUIRES_NEW)
public void ProductConfig(JSONObject object) { public void ProductConfig(JSONObject object) {
// 转换产品数组
JSONArray productArray = object.getJSONArray("productIds");
// 产品配置 // 产品配置
BsProductConfig productConfig; BsProductConfig productConfig;
for (Object product : productArray) {
ApiStarbucksProducts starbucksProducts = findStarbucksProducts(Long.valueOf(product.toString()));
productConfig = new BsProductConfig(); productConfig = new BsProductConfig();
productConfig.setProductId(Long.valueOf(product.toString())); productConfig.setProductId(object.getLong("productType"));
productConfig.setCompanyId(object.getLong("companyId")); productConfig.setCompanyId(object.getLong("companyId"));
productConfig.setCreateTime(new Date()); productConfig.setCreateTime(new Date());
productConfig.setDiscount(object.getBigDecimal("discount")); productConfig.setDiscount(object.getBigDecimal("discount"));
@ -222,12 +218,11 @@ public class ApiProductServiceImpl implements ApiProductService {
productConfig.setOperatorName(object.getString("operatorName")); productConfig.setOperatorName(object.getString("operatorName"));
productConfig.setUpdateTime(new Date()); productConfig.setUpdateTime(new Date());
productConfig.setProductName(starbucksProducts.getName()); productConfig.setProductName(ApiProductTypeEnum.getNameByType(object.getInteger("productType")));
productConfig.setProductType(object.getInteger("productType")); productConfig.setProductType(object.getInteger("productType"));
productConfigMapper.insert(productConfig); productConfigMapper.insert(productConfig);
JSONObject postObject = new JSONObject(); JSONObject postObject = new JSONObject();
postObject.put("payType", object.getJSONArray("payType")); postObject.put("payType", object.getJSONArray("payType"));
postObject.put("integralDiscount", object.getBigDecimal("integralDiscount")); postObject.put("integralDiscount", object.getBigDecimal("integralDiscount"));
@ -244,15 +239,13 @@ public class ApiProductServiceImpl implements ApiProductService {
// 配置展示平台 // 配置展示平台
commonService.configPlatform(postObject); commonService.configPlatform(postObject);
} }
}
@Override @Override
@Transactional(propagation = Propagation.REQUIRES_NEW) @Transactional(propagation = Propagation.REQUIRES_NEW)
public void updateProductConfig(JSONObject object) { public void updateProductConfig(JSONObject object) {
BsProductConfig productConfig = productConfigMapper.selectByPrimaryKey(object.getLong("id")); BsProductConfig productConfig = productConfigMapper.selectByPrimaryKey(object.getLong("id"));
ApiStarbucksProducts starbucksProducts = findStarbucksProducts(productConfig.getProductId()); productConfig.setProductId(object.getLong("productType"));
productConfig.setProductId(starbucksProducts.getId());
productConfig.setCompanyId(object.getLong("companyId")); productConfig.setCompanyId(object.getLong("companyId"));
productConfig.setDiscount(object.getBigDecimal("discount")); productConfig.setDiscount(object.getBigDecimal("discount"));
productConfig.setStatus(101); productConfig.setStatus(101);
@ -260,7 +253,7 @@ public class ApiProductServiceImpl implements ApiProductService {
productConfig.setOperatorName(object.getString("operatorName")); productConfig.setOperatorName(object.getString("operatorName"));
productConfig.setUpdateTime(new Date()); productConfig.setUpdateTime(new Date());
productConfig.setProductName(starbucksProducts.getName()); productConfig.setProductName(ApiProductTypeEnum.getNameByType(object.getInteger("productType")));
productConfig.setProductType(object.getInteger("productType")); productConfig.setProductType(object.getInteger("productType"));
productConfigMapper.updateByPrimaryKey(productConfig); productConfigMapper.updateByPrimaryKey(productConfig);

@ -33,6 +33,9 @@ public class HighGoodsTypeServiceImpl implements HighGoodsTypeService {
if (MapUtils.getString(map, "title") != null) { if (MapUtils.getString(map, "title") != null) {
criteria.andTitleLike("%" + MapUtils.getString(map, "title") + "%"); criteria.andTitleLike("%" + MapUtils.getString(map, "title") + "%");
} }
if (MapUtils.getString(map, "userService") != null) {
criteria.andUserServiceEqualTo(MapUtils.getString(map, "userService"));
}
criteria.andStatusEqualTo(1); criteria.andStatusEqualTo(1);

@ -6,19 +6,28 @@ import com.alibaba.fastjson.JSONObject;
import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode; import com.hai.common.exception.SysCode;
import com.hai.common.utils.DateUtil; import com.hai.common.pay.util.XmlUtil;
import com.hai.common.utils.HttpsUtils; import com.hai.common.pay.util.sdk.WXPayConstants;
import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.security.AESEncodeUtil;
import com.hai.common.utils.*;
import com.hai.config.*; import com.hai.config.*;
import com.hai.dao.*; import com.hai.dao.*;
import com.hai.entity.*; import com.hai.entity.*;
import com.hai.entity.OutRechargeOrder;
import com.hai.enum_type.*; import com.hai.enum_type.*;
import com.hai.model.*; import com.hai.model.*;
import com.hai.msg.entity.MsgTopic; import com.hai.msg.entity.MsgTopic;
import com.hai.service.*; import com.hai.service.*;
import com.hai.service.pay.impl.GoodsOrderServiceImpl;
import io.netty.handler.ipfilter.UniqueIpFilter; import io.netty.handler.ipfilter.UniqueIpFilter;
import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.util.EntityUtils;
import org.eclipse.paho.client.mqttv3.MqttClient; import org.eclipse.paho.client.mqttv3.MqttClient;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -28,6 +37,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.OffsetDateTime; import java.time.OffsetDateTime;
import java.util.*; import java.util.*;
@ -45,6 +55,12 @@ public class HighOrderServiceImpl implements HighOrderService {
@Resource @Resource
private HighDeviceService deviceService; private HighDeviceService deviceService;
@Resource
private BsRequestRecordService bsRequestRecordService;
@Resource
private HighUserPayPasswordService highUserPayPasswordService;
@Resource @Resource
private ThirdProductConfig thirdProductConfig; private ThirdProductConfig thirdProductConfig;
@ -128,16 +144,24 @@ public class HighOrderServiceImpl implements HighOrderService {
private RedisTemplate redisTemplate; private RedisTemplate redisTemplate;
@Resource @Resource
private MqttProviderConfig mqttProviderConfig; private GoodsOrderServiceImpl goodsOrderService;
@Resource @Resource
private WebSocket webSocket; private MqttProviderConfig mqttProviderConfig;
@Resource @Resource
private BaiduVoiceService baiduVoiceService; private BaiduVoiceService baiduVoiceService;
@Resource @Resource
private BsConfigService bsConfigService; private ApiMerchantsService apiMerchantsService;
@Resource
private ApiAmountRecordService apiAmountRecordService;
@Resource
private ApiOrderRecordService apiOrderRecordService;
@Override @Override
@Transactional( @Transactional(
@ -1772,26 +1796,166 @@ public class HighOrderServiceImpl implements HighOrderService {
} }
} }
public JSONObject insertThirdProduct(JSONObject object) throws Exception { @Override
@Transactional(
isolation = Isolation.SERIALIZABLE,
propagation = Propagation.REQUIRES_NEW)
public HighOrder insertThirdProduct(JSONObject object) throws Exception {
HighOrder highOrder = new HighOrder(); HighOrder highOrder = new HighOrder();
HighUser user = highUserService.findByUserId(object.getLong("userId")); HighUser user = highUserService.findByUserId(object.getLong("userId"));
JSONObject jsonObject = null; JSONObject jsonObject = null;
// 积分抵扣金额
BigDecimal integralPrice = new BigDecimal(0);
// 优惠券抵扣金额
BigDecimal discountPrice = new BigDecimal(0);
// 实际支付金额
BigDecimal orderPayPrice = new BigDecimal(0);
// 市场金额
BigDecimal marketPrice = new BigDecimal(0);
// 查询详单订单的实际
JSONObject productDetail = thirdProductConfig.getThirdPartyByDetail(object.getInteger("platformId"), object.getInteger("productType"), object.getLong("companyId"));
// 1 星巴克 2 肯德基 // 1 星巴克 2 肯德基
if (object.getInteger("productType") == 1) { if (object.getInteger("productType") == 1) {
jsonObject = QianZhuConfig.starbucksOrders(object.getLong("userId") , object.getString("storeCode") , object.getString("orderItems") , object.getString("customerMobile"));
JSONObject userToken = QianZhuConfig.getTokenV2(user.getId().toString(), user.getName(), user.getPhone());
if (!userToken.getBoolean("success")) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, jsonObject.getString("message"));
}
List<String> List = new ArrayList<>();
JSONArray array = object.getJSONArray("orderItems");
for (Object o : array) {
JSONObject object1 = (JSONObject) o;
Map<String, Object> contentMap = new LinkedHashMap<>();
if (!object1.getString("productId").equals("")) {
contentMap.put("productId", object1.getString("productId"));
}
if (!object1.getString("cupSize").equals("")) {
contentMap.put("cupSize", object1.getString("cupSize"));
}
if (!object1.getString("temperature").equals("")) {
contentMap.put("temperature", object1.getString("temperature"));
}
if (!object1.getString("cream").equals("")) {
contentMap.put("cream", object1.getString("cream"));
}
if (!object1.getString("espresso").equals("")) {
contentMap.put("espresso", object1.getString("espresso"));
}
if (!object1.getString("milk").equals("")) {
contentMap.put("milk", object1.getString("milk"));
}
if (!object1.getString("milkBubble").equals("")) {
contentMap.put("milkBubble", object1.getString("milkBubble"));
}
if (!object1.getString("num").equals("")) {
contentMap.put("num", object1.getString("num"));
}
List.add(JSON.toJSONString(contentMap));
}
// 下单
jsonObject = QianZhuConfig.starbucksOrders(user.getId().toString(), object.getString("storeCode"), List.toString().replace(" ", ""), object.getString("customerMobile"));
// 判断下单是否成功
if (!Objects.equals(jsonObject.getString("code"), "200")) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, jsonObject.getString("message"));
}
if (!jsonObject.getBoolean("success")) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, jsonObject.getString("message"));
}
// 根据订单号查询订单详情
JSONObject orderObject = QianZhuConfig.starbucksOrderByOrderNo(jsonObject.getJSONObject("data").getString("orderNo"));
// 判断下单是否成功
if (!orderObject.getBoolean("success")) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, jsonObject.getString("message"));
}
// 插入订单内容
highOrder.setOrderNo(jsonObject.getJSONObject("data").getString("orderNo"));
highOrder.setRegionId(object.getString("regionId"));
highOrder.setCompanyId(object.getLong("companyId"));
highOrder.setCreateTime(new Date());
highOrder.setMemId(user.getId());
highOrder.setMemName(user.getName());
highOrder.setMemPhone(user.getPhone());
highOrder.setOrderStatus(1);
highOrder.setRemarks(object.getString("userRemark"));
highOrderMapper.insert(highOrder);
// 获取星巴克订单内容
JSONArray starbucksOrder = orderObject.getJSONObject("data").getJSONArray("orderItems");
for (Object starbucksObject : starbucksOrder) {
JSONObject childObject = (JSONObject) starbucksObject;
HighChildOrder childOrder = new HighChildOrder();
childOrder.setOrderId(highOrder.getId());
childOrder.setChildOrdeStatus(1);
childOrder.setGoodsType(9);
childOrder.setStoreAddress(childObject.getString("storeAddress"));
childOrder.setStoreName(childObject.getString("storeName"));
childOrder.setGoodsName(childObject.getString("productName"));
childOrder.setGoodsImg(childObject.getString("imgUrl"));
childOrder.setSaleCount(childObject.getInteger("quantity"));
childOrder.setGoodsPrice(childObject.getBigDecimal("marketPrice"));
// String goodsSpecName = childObject.getString("cupSize") +
// "," + childObject.getString("temperature") +
// "," + childObject.getString("milk") +
// "," + childObject.getString("milkBubble") +
// "," + childObject.getString("espresso") +
// "," + childObject.getString("cream");
// childOrder.setGoodsSpecName(goodsSpecName);
// 计算利润
BigDecimal profitPrice = childObject.getBigDecimal("unitPrice").multiply(productDetail.getBigDecimal("priceDiscount").divide(new BigDecimal(100)));
BigDecimal childPrice = childObject.getBigDecimal("unitPrice").add(profitPrice).setScale(2 , RoundingMode.HALF_UP);
// 计算实际支付金额
orderPayPrice = orderPayPrice.add(childPrice);
// 计算市场价金额
marketPrice = marketPrice.add(childObject.getBigDecimal("marketPrice"));
childOrder.setGoodsActualPrice(childPrice);
childOrder.setTotalPrice(childPrice.multiply(childObject.getBigDecimal("quantity")));
highChildOrderMapper.insert(childOrder);
}
} else if (object.getInteger("productType") == 2) { } else if (object.getInteger("productType") == 2) {
if (object.getInteger("eatType") == null) { if (object.getInteger("eatType") == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请选择就餐方式!"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请选择就餐方式!");
} }
jsonObject = QianZhuConfig.createKfcOrder(object.getInteger("eatType") , object.getString("storeCode") , object.getString("customerMobile") , object.getString("orderItems") , object.getString("userId"), object.getString("userRemark")); // 下单
jsonObject = QianZhuConfig.createKfcOrder(object.getInteger("eatType"), object.getString("storeCode"), object.getString("customerMobile"), object.getString("orderItems"), object.getString("userId"));
// 判断下单是否成功
if (!Objects.equals(jsonObject.getString("code"), "10000")) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, jsonObject.getString("message"));
} }
if (jsonObject != null && jsonObject.getBoolean("success")) { // 根据订单号查询订单详情
JSONObject orderObject = QianZhuConfig.getKfcOrderByOrderNo(jsonObject.getJSONObject("data").getString("orderNo"));
// 判断下单是否成功
if (!orderObject.getBoolean("success")) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, jsonObject.getString("message"));
}
// 插入订单内容
highOrder.setOrderNo(jsonObject.getJSONObject("data").getString("orderNo")); highOrder.setOrderNo(jsonObject.getJSONObject("data").getString("orderNo"));
highOrder.setRegionId(object.getString("regionId")); highOrder.setRegionId(object.getString("regionId"));
highOrder.setCompanyId(object.getLong("companyId"));
highOrder.setCreateTime(new Date()); highOrder.setCreateTime(new Date());
highOrder.setMemId(user.getId()); highOrder.setMemId(user.getId());
highOrder.setMemName(user.getName()); highOrder.setMemName(user.getName());
@ -1801,11 +1965,498 @@ public class HighOrderServiceImpl implements HighOrderService {
highOrderMapper.insert(highOrder); highOrderMapper.insert(highOrder);
return jsonObject.getJSONObject("data"); // 获取肯德基订单内容
JSONArray kfcOrder = orderObject.getJSONObject("data").getJSONObject("kfcPlaceOrder").getJSONArray("items");
for (Object kfcObject : kfcOrder) {
JSONObject childObject = (JSONObject) kfcObject;
HighChildOrder childOrder = new HighChildOrder();
childOrder.setOrderId(highOrder.getId());
childOrder.setChildOrdeStatus(1);
childOrder.setGoodsType(4);
childOrder.setStoreAddress(orderObject.getJSONObject("data").getJSONObject("kfcPlaceOrder").getString("storeAddress"));
childOrder.setStoreName(orderObject.getJSONObject("data").getJSONObject("kfcPlaceOrder").getString("storeName"));
childOrder.setGoodsName(childObject.getString("productName"));
childOrder.setGoodsImg(childObject.getString("imageUrl"));
childOrder.setSaleCount(childObject.getInteger("quantity"));
childOrder.setGoodsPrice(childObject.getBigDecimal("originPrice"));
// 计算利润
BigDecimal profitPrice = childObject.getBigDecimal("price").multiply(productDetail.getBigDecimal("priceDiscount").divide(new BigDecimal(100)));
BigDecimal childPrice = childObject.getBigDecimal("price").add(profitPrice).setScale(2 , RoundingMode.HALF_UP);
// 计算实际支付金额
orderPayPrice = orderPayPrice.add(childPrice);
// 计算市场价金额
marketPrice = marketPrice.add(childObject.getBigDecimal("originPrice"));
childOrder.setGoodsActualPrice(childPrice);
childOrder.setTotalPrice(childPrice.multiply(childObject.getBigDecimal("quantity")));
highChildOrderMapper.insert(childOrder);
}
}
// 定义优惠券
HighDiscountUserRel highDiscountUserRel = null;
// 判断是否有优惠券
if (object.getLong("memDiscountId") != null) {
// 优惠券信息
highDiscountUserRel = highDiscountUserRelService.getRelById(object.getLong("memDiscountId"));
highOrder.setMemDiscountId(object.getLong("memDiscountId"));
if (highDiscountUserRel == null || highDiscountUserRel.getStatus() != 1) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券状态错误");
}
if (!highDiscountUserRel.getHighDiscount().getUseScope().equals(DiscountUseScope.type1.getType())
&& !highDiscountUserRel.getHighDiscount().getUseScope().equals(DiscountUseScope.type3.getType())) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法使用此优惠券");
}
}
// 使用优惠券
// 优惠券抵扣
if (highDiscountUserRel != null) {
highOrder.setMemDiscountName(highDiscountUserRel.getHighDiscount().getDiscountName());
// 卡卷类型 1:满减 2:抵扣 3:折扣
if (highDiscountUserRel.getHighDiscount().getDiscountType() == 1) {
// 如果商品支付总额 小于 满减价格
if (orderPayPrice.compareTo(highDiscountUserRel.getHighDiscount().getDiscountCondition()) < 0) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.UN_MEMBER_ERROR, "订单未达到" + highDiscountUserRel.getHighDiscount().getDiscountCondition() + "元,无法使用此优惠券");
}
// 满减额度
discountPrice = highDiscountUserRel.getHighDiscount().getDiscountPrice();
}
// 卡卷类型 1:满减 2:抵扣 3:折扣
if (highDiscountUserRel.getHighDiscount().getDiscountType() == 2) {
// 满减额度
discountPrice = highDiscountUserRel.getHighDiscount().getDiscountPrice();
}
// 卡卷类型 1:满减 2:抵扣 3:折扣
if (highDiscountUserRel.getHighDiscount().getDiscountType() == 3) {
// 满减额度
discountPrice = orderPayPrice.multiply(highDiscountUserRel.getHighDiscount().getDiscountPrice());
}
}
// 使用积分
// 判断积分数量是否大于0
if (object.getLong("integralNum") != null) {
if (object.getLong("integralNum") > 0 && productDetail.getBigDecimal("integralDiscount").compareTo(new BigDecimal("0")) > 0) {
// 判断用户积分是否够
if (object.getLong("integralNum") > user.getGold()) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "用户积分不足");
}
// 积分抵扣金额
integralPrice = object.getBigDecimal("integralNum").divide(new BigDecimal(100).setScale(2, RoundingMode.HALF_UP));
// 最高可抵扣金额
BigDecimal maxIntegralDeductionPrice = orderPayPrice.multiply(productDetail.getBigDecimal("integralDiscount")).divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_UP);
// 判读积分是否大于限制额度
if (maxIntegralDeductionPrice.compareTo(integralPrice) < 0) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单最大抵扣积分金额:" + maxIntegralDeductionPrice);
}
// 判断积分抵扣比例是否为100% 并且积分数量是否可以抵扣最后的支付金额
if (productDetail.getBigDecimal("integralDiscount").compareTo(new BigDecimal(100)) == 0 && integralPrice.compareTo(orderPayPrice) == 0) {
// 查询用户支付密码
HighUserPayPassword userPayPassword = highUserPayPasswordService.getDetailByUser(object.getLong("userId"));
if (userPayPassword == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_SET_USER_PAY_PWD, "");
}
if (StringUtils.isBlank(object.getString("password"))) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_ENTER_USER_PAY_PWD, "");
}
// 校验支付密码
if (!AESEncodeUtil.aesEncrypt(object.getString("password")).equals(userPayPassword.getPassword())) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.USER_PAY_PWD_ERROR, "");
}
}
}
}
highOrder.setPayPrice(orderPayPrice);
highOrder.setDeductionPrice(discountPrice);
highOrder.setPayGold(object.getInteger("integralNum"));
// 使用优惠券 或者积分
if (highOrder.getMemDiscountId() != null) {
highOrder.setTotalPrice(marketPrice);
highOrder.setPayPrice(marketPrice.subtract(discountPrice));
HighDiscountUserRel discountUserRel = highDiscountUserRelService.getRelById(highOrder.getMemDiscountId());
discountUserRel.setUseTime(new Date()); // 使用时间
discountUserRel.setStatus(2); //状态 0:已过期 1:未使用 2:已使用
highDiscountUserRelService.updateDiscountUserRel(discountUserRel);
HighDiscountAgentCode code = highDiscountAgentCodeService.getCodeById(discountUserRel.getDiscountAgentCodeId());
code.setStatus(3);
highDiscountAgentCodeService.updateCode(code);
} else {
highOrder.setTotalPrice(orderPayPrice);
highOrder.setPayPrice(orderPayPrice.subtract(discountPrice));
}
if (integralPrice.compareTo(new BigDecimal(0)) > 0) {
highOrder.setPayPrice(highOrder.getPayPrice().subtract(integralPrice));
highUserService.goldHandle(highOrder.getMemId(), object.getInteger("integralNum"), 2, 2, highOrder.getId());
}
// 判断积分支付是否扣完金额
if (highOrder.getPayPrice().compareTo(new BigDecimal(0)) == 0) {
highOrder.setOrderStatus(2);
highOrder.setPayModel(1);
highOrder.setPayType(3);
highOrder.setPayTime(new Date());
highOrder.setPaySerialNo("HF" + DateUtil.date2String(new Date(), "yyyyMMddHHmmss") + IDGenerator.nextId(5));
} else { } else {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR , jsonObject.getString("message")); highOrder.setOrderStatus(1);
} }
highOrder.setPayRealPrice(highOrder.getPayPrice());
highOrder.setRemarks(object.getString("customerMobile"));
highOrderMapper.updateByPrimaryKey(highOrder);
if (highOrder.getOrderStatus() == 2) {
HighOrder highOrderList = highOrderService.getOrderById(highOrder.getId());
for (HighChildOrder childOrder : highOrderList.getHighChildOrderList()) {
childOrder.setChildOrdeStatus(2);
}
// 1 星巴克 2 肯德基 3:第三方会员充值
if (object.getInteger("productType") == 1) {
QianZhuConfig.starbucksOrdersPay(highOrder.getOrderNo());
} else if (object.getInteger("productType") == 2){
QianZhuConfig.payKfcOrder(highOrder.getOrderNo());
} }
} }
// 创建提交记录
BsRequestRecord requestRecord = new BsRequestRecord();
requestRecord.setCreateTime(new Date());
requestRecord.setUpdateTime(new Date());
requestRecord.setOrderNo(highOrder.getOrderNo());
requestRecord.setRequestContent(object.toJSONString());
requestRecord.setOperatorId(0L);
requestRecord.setOperatorName("系统生成");
requestRecord.setSourceId(highOrder.getId().toString());
requestRecord.setSourceType(1);
bsRequestRecordService.insertRequestRecord(requestRecord);
return highOrder;
}
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void hltUnionCardPayByThirdProduct(HighUserCard userCard, Long orderId) throws Exception {
String goodsDesc = "";
String tranDesc = "";
String instCode = "11101527";
String businessType = "hisen_consume";
// 查询订单信息
HighOrder order = getOrderById(orderId);
if (order == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_ORDER, "");
}
if (order.getHighChildOrderList().get(0).getGoodsType() == 4) {
goodsDesc = "购买肯德基产品";
tranDesc = goodsDesc + order.getPayRealPrice() + "元";
} else if (order.getHighChildOrderList().get(0).getGoodsType() == 9) {
goodsDesc = "购买星巴克产品";
tranDesc = goodsDesc + order.getPayRealPrice() + "元";
} else {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂时无法支付,请使用其他支付方式");
}
// 工会卡支付
JSONObject consumption = HuiLianTongUnionCardConfig.consumption(order.getOrderNo(), userCard.getCardNo(), order.getPayRealPrice(), businessType, instCode, goodsDesc, tranDesc);
System.out.println("工会卡支付响应参数" + consumption.toJSONString());
Map<String, Object> dataMap = new HashMap<>();
dataMap.put("orderNo", order.getOrderNo());
dataMap.put("cardType", "ghk");
dataMap.put("cardNo", userCard.getCardNo());
dataMap.put("checkPassword", "N");
dataMap.put("tranAmount", order.getPayRealPrice());
dataMap.put("tranChannel", "HiSen");
dataMap.put("businessType", businessType);
dataMap.put("instCode", instCode);
dataMap.put("goodsDesc", goodsDesc);
dataMap.put("tranDesc", tranDesc);
HighGasOrderPush payPush = new HighGasOrderPush();
payPush.setType(OrderPushType.type5.getType());
payPush.setOrderNo(order.getOrderNo());
payPush.setCreateTime(new Date());
payPush.setCode(consumption.getString("respCode"));
payPush.setRequestContent(JSON.toJSONString(dataMap));
payPush.setReturnContent(consumption.toJSONString());
highGasOrderPushMapper.insert(payPush);
if (!consumption.getString("respCode").equals("0000")) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumption.getString("respMessage"));
}
JSONObject consumptionResult = HuiLianTongUnionCardConfig.resolveResponse(consumption.getString("data"));
if (!consumptionResult.getBoolean("success")) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumptionResult.getString("message"));
}
order.setPaySerialNo(consumptionResult.getString("orderId")); // 支付流水号
order.setOrderStatus(2);
order.setMemCardNo(userCard.getCardNo());
order.setPayType(4);
order.setPayTime(new Date()); // 支付时间
updateOrder(order);
for (HighChildOrder childOrder : order.getHighChildOrderList()) {
childOrder.setChildOrdeStatus(2);
}
if (order.getHighChildOrderList().get(0).getGoodsType() == 4) {
QianZhuConfig.payKfcOrder(order.getOrderNo());
} else if (order.getHighChildOrderList().get(0).getGoodsType() == 9) {
QianZhuConfig.starbucksOrdersPay(order.getOrderNo());
} else {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂时无法支付,请使用其他支付方式");
}
}
@Override
public List<HighOrder> getThirdOrder() {
return highOrderMapper.getThirdOrder();
}
@Override
public void thirdOrderToRefund(Long orderId) throws Exception {
HighOrder order = highOrderService.getOrderById(orderId);
// 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款
if (order.getOrderStatus() != 2) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单不处于已支付状态");
}
// 退还积分
if (order.getPayGold() > 0) {
highUserService.goldHandle(order.getMemId(), order.getPayGold(), 1, 3, order.getId());
if (order.getPayRealPrice().compareTo(new BigDecimal(0)) == 0) {
order.setOrderStatus(4);
order.setRefundTime(new Date());
for (HighChildOrder childOrder : order.getHighChildOrderList()) {
childOrder.setChildOrdeStatus(4);
}
updateOrder(order);
}
}
// 微信退款
if (order.getPayType() == 2) {
Map<String, String> param = new HashMap<>();
param.put("appid", "wx637bd6f7314daa46");
param.put("mch_id", "1289663601");
param.put("sub_mch_id", "1614670195");
param.put("nonce_str", WxUtils.makeNonStr());
param.put("transaction_id", order.getPaySerialNo());
param.put("out_refund_no", "HFR" + new Date().getTime());
param.put("total_fee", String.valueOf(order.getPayRealPrice().multiply(new BigDecimal("100")).intValue()));
param.put("refund_fee", String.valueOf(order.getPayRealPrice().multiply(new BigDecimal("100")).intValue()));
param.put("sign_type", "HMAC-SHA256");
String signStr = WxUtils.generateSignature(param, "Skufk5oi85wDFGl888i6wsRSTkdd5df5", WXPayConstants.SignType.HMACSHA256);
param.put("sign", signStr);
String resultXmL = doRefundRequest(param.get("mch_id"), WxUtils.mapToXml(param));
OrderRefundModel orderRefundModel = XmlUtil.getObjectFromXML(resultXmL, OrderRefundModel.class);
if (orderRefundModel.getResult_code().equals("SUCCESS")) {
order.setRefundTime(new Date());
order.setRefundNo(orderRefundModel.getOut_refund_no());
order.setRefundPrice(new BigDecimal(orderRefundModel.getRefund_fee()).divide(new BigDecimal("100")));
order.setOrderStatus(4);
order.setRefundTime(new Date());
for (HighChildOrder childOrder : order.getHighChildOrderList()) {
childOrder.setChildOrdeStatus(4);
}
updateOrder(order);
} else {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "退款失败!错误代码:" + orderRefundModel.getErr_code() + ",错误描述" + orderRefundModel.getErr_code_des());
}
}
// 工会卡退款
if (order.getPayType() == 3) {
JSONObject jsonObject = HuiLianTongUnionCardConfig.refund("HFR" + new Date().getTime(), order.getOrderNo());
if (jsonObject == null) {
jsonObject = HuiLianTongUnionCardConfig.refund("HFR" + new Date().getTime(), order.getOrderNo());
}
JSONObject dataObject = HuiLianTongUnionCardConfig.resolveResponse(jsonObject.getString("data"));
if (dataObject.getBoolean("success") || Objects.equals(dataObject.getString("message"), "原交易已撤销,不可再次操作")) {
order.setRefundTime(new Date());
order.setRefundNo("HFR" + new Date().getTime());
order.setRefundPrice(order.getPayRealPrice());
order.setOrderStatus(4);
order.setRefundTime(new Date());
for (HighChildOrder childOrder : order.getHighChildOrderList()) {
childOrder.setChildOrdeStatus(4);
}
updateOrder(order);
} else {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, dataObject.getString("message"));
}
// 商户预充值 帐户退款
if (order.getPayType() == 6) {
Map<String , Object> map = new HashMap<>();
map.put("orderNo" , order.getOrderNo());
map.put("amountType" , 1);
map.put("sourceType" , 2);
if ( apiAmountRecordService.getApiAmountRecordByList(map).size() == 1) {
ApiMerchants apiMerchants = apiMerchantsService.findByMchId(order.getMerchId());
// 插入金额记录
// 变更前金额
BigDecimal beforeAmount = apiMerchants.getAmounts();
// 计算金额
apiMerchants.setAmounts(apiMerchants.getAmounts().add(order.getPayPrice()));
// 变更后金额
BigDecimal afterAmount = apiMerchants.getAmounts();
apiMerchantsService.updateApiMerchants(apiMerchants);
ApiAmountRecord apiAmountRecord = new ApiAmountRecord();
apiAmountRecord.setCreateTime(new Date());
apiAmountRecord.setUpdateTime(new Date());
apiAmountRecord.setMchId(order.getMerchId());
apiAmountRecord.setStatus(100);
apiAmountRecord.setAmount(order.getPayPrice());
apiAmountRecord.setAfterAmount(afterAmount);
apiAmountRecord.setBeforeAmount(beforeAmount);
apiAmountRecord.setAmountType(1);
apiAmountRecord.setSourceType(2);
apiAmountRecord.setSourceOrderNo(order.getOrderNo());
apiAmountRecord.setSourceId(order.getId());
apiAmountRecord.setSourceContent(apiMerchants.getMerchantName() + "|订单退款" + order.getPayPrice());
apiAmountRecordService.insertAmountRecord(apiAmountRecord);
Map<String, Object> orderMap = new HashMap<>();
orderMap.put("orderId" , order.getId());
// 查询是否用重复订单
ApiOrderRecord apiOrderRecord = apiOrderRecordService.queryOrderResult(orderMap);
apiOrderRecord.setStatus(100);
apiOrderRecord.setRequestTime(new Date());
apiOrderRecordService.updateOrderRecord(apiOrderRecord);
}
}
}
// 银联退款
if (order.getPayType() == 4) {
// 订单退款
JSONObject refund = UnionPayConfig.zwrefund(UnionPayConfig.MER_ID2, UnionPayConfig.TERM_ID2, order.getOrderNo(), order.getPaySerialNo(), order.getPayRealPrice().multiply(new BigDecimal("100")).longValue());
if (!refund.getString("resultcode").equals("W6")) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, refund.getString("returnmsg"));
}
order.setRefundTime(new Date());
order.setRefundNo(refund.getString("oriwtorderid"));
order.setRefundPrice(order.getPayRealPrice());
order.setOrderStatus(4);
order.setRefundTime(new Date());
for (HighChildOrder childOrder : order.getHighChildOrderList()) {
childOrder.setChildOrdeStatus(4);
}
updateOrder(order);
}
if (order.getMemDiscountId() != null) {
HighDiscountUserRel rel = highDiscountUserRelService.getRelById(order.getMemDiscountId());
if (rel != null) {
rel.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用
rel.setUseTime(null);
highDiscountUserRelService.updateDiscountUserRel(rel);
HighDiscountAgentCode code = highDiscountAgentCodeService.getCodeById(rel.getDiscountAgentCodeId());
code.setStatus(2);
highDiscountAgentCodeService.updateCode(code);
}
}
}
public String doRefundRequest(String mchId, String data) throws Exception {
//小程序退款需要调用双向证书的认证
CloseableHttpClient httpClient = goodsOrderService.readCertificate(mchId);
try {
HttpPost httpost = new HttpPost("https://api.mch.weixin.qq.com/secapi/pay/refund"); // 设置响应头信息
httpost.addHeader("Connection", "keep-alive");
httpost.addHeader("Accept", "*/*");
httpost.addHeader("Content-Type", "text/xml");
httpost.addHeader("Host", "api.mch.weixin.qq.com");
httpost.addHeader("X-Requested-With", "XMLHttpRequest");
httpost.addHeader("Cache-Control", "max-age=0");
httpost.addHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0) ");
httpost.setEntity(new StringEntity(data, "UTF-8"));
CloseableHttpResponse response = httpClient.execute(httpost);
try {
HttpEntity entity = response.getEntity();
String jsonStr = EntityUtils.toString(response.getEntity(), "UTF-8");
EntityUtils.consume(entity);
return jsonStr;
} finally {
response.close();
}
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
httpClient.close();
}
}
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void thirdCancelOrder(Long orderId) {
HighOrder order = getOrderById(orderId);
if (order != null && order.getOrderStatus() == 1) {
order.setOrderStatus(5);
order.setCancelTime(new Date());
for (HighChildOrder childOrder : order.getHighChildOrderList()) {
childOrder.setChildOrdeStatus(5);
}
if (order.getMemDiscountId() != null) {
HighDiscountUserRel rel = highDiscountUserRelService.getRelById(order.getMemDiscountId());
if (rel != null) {
rel.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用
rel.setUseTime(null);
highDiscountUserRelService.updateDiscountUserRel(rel);
HighDiscountAgentCode code = highDiscountAgentCodeService.getCodeById(rel.getDiscountAgentCodeId());
code.setStatus(2);
highDiscountAgentCodeService.updateCode(code);
}
}
if (order.getPayGold() != null) {
// 积分返回
highUserService.goldHandle(order.getMemId(), order.getPayGold(), 1, 3, order.getId());
}
updateOrder(order);
}
}
}

@ -596,7 +596,6 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
public void rechargeOrderToRefund(Long orderId) throws Exception { public void rechargeOrderToRefund(Long orderId) throws Exception {
OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId); OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId);
System.out.println("发起退款------------------------------------------------------------------------------" + orderId);
// 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款 // 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款
if (order.getPayStatus() != 102) { if (order.getPayStatus() != 102) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单不处于已支付状态"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单不处于已支付状态");

@ -0,0 +1,61 @@
package com.hai.service.pay.impl;
import com.alibaba.fastjson.JSONObject;
import com.hai.config.QianZhuConfig;
import com.hai.dao.HighGasOrderPushMapper;
import com.hai.entity.HighChildOrder;
import com.hai.entity.HighGasOrderPush;
import com.hai.entity.HighOrder;
import com.hai.enum_type.OrderPushType;
import com.hai.service.HighOrderService;
import com.hai.service.pay.PayService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Date;
import java.util.Map;
@Service("starbucksOrderService")
public class StarbucksOrderServiceImpl implements PayService {
@Resource
private HighOrderService highOrderService;
@Resource
private HighGasOrderPushMapper highGasOrderPushMapper;
@Override
public void paySuccess(Map<String, String> map, String payType) throws Exception {
if (payType.equals("Alipay")) {
return;
}
if (payType.equals("WechatPay")) {
HighOrder order = highOrderService.getOrderByOrderNo(map.get("out_trade_no"));
if (order != null && order.getOrderStatus() == 1) {
order.setPaySerialNo(map.get("transaction_id")); // 支付流水号
order.setPayRealPrice(new BigDecimal(map.get("total_fee")).divide(new BigDecimal("100"))); // 实付金额
order.setPayTime(new Date()); // 支付时间
order.setPayModel(2); // 支付模式:1 金币,2 第三方平台,3 混合
order.setPayType(2); // 支付方式: 1:支付宝 2:微信 3:金币
order.setOrderStatus(2); // 订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消
for (HighChildOrder childOrder : order.getHighChildOrderList()) {
childOrder.setChildOrdeStatus(2); // 子订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消
}
highOrderService.updateOrder(order);
// 支付给千猪
JSONObject object = QianZhuConfig.starbucksOrdersPay(order.getOrderNo());
// 推送订单记录
HighGasOrderPush highGasOrderPush = new HighGasOrderPush();
highGasOrderPush.setType(OrderPushType.type3.getType());
highGasOrderPush.setOrderNo(order.getOrderNo());
highGasOrderPush.setCreateTime(new Date());
highGasOrderPush.setRequestContent(order.getOrderNo());
highGasOrderPush.setReturnContent(object.toJSONString());
highGasOrderPushMapper.insert(highGasOrderPush);
}
}
}
}

@ -18,7 +18,11 @@ qinzhuHtmlUrl=https://m-test.qianzhu8.com
qianzhuH5url=https://nf-test.qianzhu8.com/gateway qianzhuH5url=https://nf-test.qianzhu8.com/gateway
qinzhuPlatformId=10376 qinzhuPlatformId=10376
qinzhuSecret=ktxb49sh2jfhgn8g qinzhuSecret=ktxb49sh2jfhgn8g
qianzhuOrderNotify=https://hsg.dctpay.com/crest/qianzhu/orderNotify qianzhuOrderNotify=https://hsgcs.dctpay.com/crest/qianzhu/orderNotify
thirdAppKey=211394653
thirdAppSecret=cyQpQKMaGUG186iEZRt1uQ==
thirdPostUrl=http://mbsmemberwebapi.test.onfishes.com/
# ??????? # ???????
huiliantongUrl=https://gzapitest.deepermobile.com.cn:441 huiliantongUrl=https://gzapitest.deepermobile.com.cn:441

@ -17,6 +17,12 @@ qinzhuPlatformId=10458
qinzhuSecret=nnl3gg4ss0pka11t qinzhuSecret=nnl3gg4ss0pka11t
qianzhuOrderNotify=https://hsg.dctpay.com/crest/qianzhu/orderNotify qianzhuOrderNotify=https://hsg.dctpay.com/crest/qianzhu/orderNotify
thirdAppKey=211394653
thirdAppSecret=cyQpQKMaGUG186iEZRt1uQ==
thirdPostUrl=http://mbsmemberwebapi.test.onfishes.com/
huiliantongUrl=https://gzapi.deepermobile.com.cn huiliantongUrl=https://gzapi.deepermobile.com.cn
huiliantongAppNo=guizhouhuilt huiliantongAppNo=guizhouhuilt
huiliantongAppkey=e0ja2Ex%2BmQ2hIPF6x%2BHA%3D huiliantongAppkey=e0ja2Ex%2BmQ2hIPF6x%2BHA%3D

@ -17,6 +17,10 @@ qinzhuPlatformId=10458
qinzhuSecret=nnl3gg4ss0pka11t qinzhuSecret=nnl3gg4ss0pka11t
qianzhuOrderNotify=https://hsg.dctpay.com/crest/qianzhu/orderNotify qianzhuOrderNotify=https://hsg.dctpay.com/crest/qianzhu/orderNotify
thirdAppKey=211394653
thirdAppSecret=cyQpQKMaGUG186iEZRt1uQ==
thirdPostUrl=http://mbsmemberwebapi.test.onfishes.com/
huiliantongUrl=https://gzapi.deepermobile.com.cn huiliantongUrl=https://gzapi.deepermobile.com.cn
huiliantongAppNo=guizhouhuilt huiliantongAppNo=guizhouhuilt
huiliantongAppkey=e0ja2Ex%2BmQ2hIPF6x%2BHA%3D huiliantongAppkey=e0ja2Ex%2BmQ2hIPF6x%2BHA%3D

Loading…
Cancel
Save