master
袁野 4 months ago
commit de0e4888d9
  1. 53
      bweb/src/main/java/com/bweb/controller/SecMenuController.java
  2. 23
      cweb/src/main/java/com/cweb/controller/CommonController.java
  3. 18
      cweb/src/main/java/com/cweb/controller/qianZhu/StarbucksController.java
  4. 2
      order/src/main/java/com/order/controller/OrderController.java
  5. 7
      order/src/main/java/com/order/controller/business/BsOrderStarbucksController.java
  6. 83
      service/src/main/java/com/hfkj/common/utils/StarbucksUtil.java
  7. 2
      service/src/main/java/com/hfkj/model/order/OrderStarbucksModel.java
  8. 17
      service/src/main/java/com/hfkj/qianzhu/channel/StarbucksService.java
  9. 2
      service/src/main/java/com/hfkj/service/cms/impl/CmsContentServiceImpl.java
  10. 8
      service/src/main/java/com/hfkj/service/order/OrderCreateService.java
  11. 13
      service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java
  12. 75
      service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java
  13. 12
      service/src/main/resources/dev/commonConfig.properties

@ -1,17 +1,12 @@
package com.bweb.controller; package com.bweb.controller;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hfkj.common.exception.ErrorCode; import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode; import com.hfkj.common.exception.SysCode;
import com.hfkj.common.utils.HttpUtils;
import com.hfkj.common.utils.HttpsUtils;
import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.entity.SecMenu; import com.hfkj.entity.SecMenu;
import com.hfkj.entity.SecRoleMenuRel; import com.hfkj.entity.SecRoleMenuRel;
import com.hfkj.model.MenuTreeModel;
import com.hfkj.model.ResponseData; import com.hfkj.model.ResponseData;
import com.hfkj.service.SecMenuService; import com.hfkj.service.SecMenuService;
import com.hfkj.service.SecRoleMenuRelService; import com.hfkj.service.SecRoleMenuRelService;
@ -26,7 +21,6 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.*; import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -174,39 +168,10 @@ public class SecMenuController {
try { try {
// 查询角色菜单权限 // 查询角色菜单权限
Map<Long, SecMenu> roleMenu = secMenuService.queryRoleMenu(roleId, SecMenuTypeEnum.type1).stream() List<SecRoleMenuRel> roleMenuList = secRoleMenuRelService.getRelListByRole(roleId);
.collect(Collectors.toMap(SecMenu::getId, Function.identity()));
// 系统菜单叶节点 return ResponseMsgUtil.success(roleMenuList.stream().map(SecRoleMenuRel::getMenuId).collect(Collectors.toList())
List<String> menuLeafList = new ArrayList<>(); .stream().map(Object::toString).collect(Collectors.toList()));
// 角色菜单叶节点
List<String> roleLeafList = new ArrayList<>();
// 获取全部菜单
List<SecMenu> menuList = secMenuService.getAllList();
// 获取最顶层菜单
List<SecMenu> topLevelMenuList = menuList.stream()
.filter(o -> o.getMenuPSid() == null)
.sorted(Comparator.comparing(SecMenu::getMenuSort))
.collect(Collectors.toList());
// 递归获取系统菜单叶子节点
for (SecMenu topLevelMenu : topLevelMenuList) {
if (topLevelMenu.getMenuType().equals(SecMenuTypeEnum.type1.getCode())) {
recursionMenu(menuList, topLevelMenu.getId(), menuLeafList);
}
}
// 筛选角色菜单叶节点
for (String leaf : menuLeafList) {
SecMenu menu = roleMenu.get(Long.parseLong(leaf));
if (menu != null) {
roleLeafList.add(""+menu.getId());
}
}
return ResponseMsgUtil.success(roleLeafList);
} catch (Exception e) { } catch (Exception e) {
log.error("error!",e); log.error("error!",e);
@ -247,11 +212,11 @@ public class SecMenuController {
for (SecMenu topLevelMenu : topLevelMenuList) { for (SecMenu topLevelMenu : topLevelMenuList) {
if (topLevelMenu.getMenuType().equals(SecMenuTypeEnum.type1.getCode())) { if (topLevelMenu.getMenuType().equals(SecMenuTypeEnum.type1.getCode())) {
map = new LinkedHashMap<>(); map = new HashMap<>();
map.put("key", ""+topLevelMenu.getId()); map.put("key", ""+topLevelMenu.getId());
map.put("title", topLevelMenu.getMenuName()); map.put("title", topLevelMenu.getMenuName());
// 获取下级菜单 // 获取下级菜单
map.put("children", recursionMenu(menuList, topLevelMenu.getId(), new ArrayList<>())); map.put("children", recursionMenu(menuList, topLevelMenu.getId()));
mapList.add(map); mapList.add(map);
} }
} }
@ -270,7 +235,7 @@ public class SecMenuController {
* @param parentMenuId 父级菜单id * @param parentMenuId 父级菜单id
* @return * @return
*/ */
public List<Map<String,Object>> recursionMenu(List<SecMenu> dataSource, Long parentMenuId, List<String> leaf) { public List<Map<String,Object>> recursionMenu(List<SecMenu> dataSource, Long parentMenuId) {
List<Map<String,Object>> mapList = new ArrayList<>(); List<Map<String,Object>> mapList = new ArrayList<>();
Map<String,Object> map; Map<String,Object> map;
@ -280,13 +245,12 @@ public class SecMenuController {
.collect(Collectors.toList()); .collect(Collectors.toList());
for (SecMenu menu : collect) { for (SecMenu menu : collect) {
if (menu.getMenuType().equals(SecMenuTypeEnum.type1.getCode())) { if (menu.getMenuType().equals(SecMenuTypeEnum.type1.getCode())) {
map = new LinkedHashMap<>(); map = new HashMap<>();
map.put("key", ""+menu.getId()); map.put("key", ""+menu.getId());
map.put("title", menu.getMenuName()); map.put("title", menu.getMenuName());
// 获取下级菜单 // 获取下级菜单
List<Map<String, Object>> recursioned = recursionMenu(dataSource, menu.getId(), leaf); List<Map<String, Object>> recursioned = recursionMenu(dataSource, menu.getId());
if (recursioned.isEmpty()) { if (recursioned.isEmpty()) {
leaf.add(""+menu.getId());
map.put("isLeaf", true); map.put("isLeaf", true);
} else { } else {
map.put("children", recursioned); map.put("children", recursioned);
@ -297,5 +261,4 @@ public class SecMenuController {
return mapList; return mapList;
} }
} }

@ -12,6 +12,7 @@ import com.hfkj.model.ResponseData;
import com.hfkj.qianzhu.channel.QianZhuService; import com.hfkj.qianzhu.channel.QianZhuService;
import com.hfkj.service.CommonService; import com.hfkj.service.CommonService;
import com.hfkj.service.goods.BsOrderGoodsService; import com.hfkj.service.goods.BsOrderGoodsService;
import com.hfkj.service.hlt.HuiLianTongUnionCardService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -40,6 +41,28 @@ public class CommonController {
@Resource @Resource
private BsOrderGoodsService bsOrderGoodsService; private BsOrderGoodsService bsOrderGoodsService;
@RequestMapping(value = "/test", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "test")
public ResponseData test() {
try {
JSONObject refundObj = HuiLianTongUnionCardService.refund("R240805090735776", "240803201355633339");
if (!refundObj.getString("respCode").equals("0000")) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, refundObj.getString("respMessage"));
}
JSONObject consumptionResult = HuiLianTongUnionCardService.resolveResponse(refundObj.getString("data"));
if (!(consumptionResult.getBoolean("success") || Objects.equals(consumptionResult.getString("message"), "原交易已撤销,不可再次操作"))) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "退款失败!"+consumptionResult.getString("message"));
}
return ResponseMsgUtil.success(consumptionResult);
} catch (Exception e) {
log.error("HighUserCardController --> oilCardRefund() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/getAllCity", method = RequestMethod.GET) @RequestMapping(value = "/getAllCity", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "查询所有城市") @ApiOperation(value = "查询所有城市")

@ -26,10 +26,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -84,7 +81,7 @@ public class StarbucksController {
// 查询产品 // 查询产品
Map<String , Object> map = new HashMap<>(); Map<String , Object> map = new HashMap<>();
map.put("pageIndex", 1); map.put("pageIndex", 1);
map.put("pageSize", 100000); map.put("pageSize", 200);
JSONObject object = StarbucksService.starbucksProducts(map); JSONObject object = StarbucksService.starbucksProducts(map);
if (object.getJSONObject("data") != null) { if (object.getJSONObject("data") != null) {
JSONArray jsonArray = object.getJSONObject("data").getJSONArray("items"); JSONArray jsonArray = object.getJSONObject("data").getJSONArray("items");
@ -96,29 +93,40 @@ public class StarbucksController {
// 中杯售卖价 // 中杯售卖价
BigDecimal tallPrice = StarbucksUtil.calculatePrice(productConfig.getDiscount() , item.getBigDecimal("salesTallPrice")); BigDecimal tallPrice = StarbucksUtil.calculatePrice(productConfig.getDiscount() , item.getBigDecimal("salesTallPrice"));
List<BigDecimal> priceList = new ArrayList<>();
// 判断如果卖家 大于 原价 展示原价 // 判断如果卖家 大于 原价 展示原价
if (tallPrice.compareTo(item.getBigDecimal("marketTallPrice")) > 0) { if (tallPrice.compareTo(item.getBigDecimal("marketTallPrice")) > 0) {
item.put("tallPrice" , item.getBigDecimal("marketTallPrice")); item.put("tallPrice" , item.getBigDecimal("marketTallPrice"));
priceList.add(item.getBigDecimal("marketTallPrice"));
} else { } else {
item.put("tallPrice" , tallPrice); item.put("tallPrice" , tallPrice);
priceList.add(tallPrice);
} }
// 大杯销售价 // 大杯销售价
BigDecimal grandePrice = StarbucksUtil.calculatePrice(productConfig.getDiscount() , item.getBigDecimal("salesGrandePrice")); BigDecimal grandePrice = StarbucksUtil.calculatePrice(productConfig.getDiscount() , item.getBigDecimal("salesGrandePrice"));
if (grandePrice.compareTo(item.getBigDecimal("marketGrandePrice")) > 0) { if (grandePrice.compareTo(item.getBigDecimal("marketGrandePrice")) > 0) {
item.put("grandePrice" , item.getBigDecimal("marketGrandePrice")); item.put("grandePrice" , item.getBigDecimal("marketGrandePrice"));
priceList.add(item.getBigDecimal("marketGrandePrice"));
} else { } else {
item.put("grandePrice" , grandePrice); item.put("grandePrice" , grandePrice);
priceList.add(grandePrice);
} }
// 超大杯销售价 // 超大杯销售价
BigDecimal ventiPrice = StarbucksUtil.calculatePrice(productConfig.getDiscount() , item.getBigDecimal("salesVentiPrice")); BigDecimal ventiPrice = StarbucksUtil.calculatePrice(productConfig.getDiscount() , item.getBigDecimal("salesVentiPrice"));
if (ventiPrice.compareTo(item.getBigDecimal("marketVentiPrice")) > 0) { if (ventiPrice.compareTo(item.getBigDecimal("marketVentiPrice")) > 0) {
item.put("ventiPrice" , item.getBigDecimal("marketVentiPrice")); item.put("ventiPrice" , item.getBigDecimal("marketVentiPrice"));
priceList.add(item.getBigDecimal("marketVentiPrice"));
} else { } else {
item.put("ventiPrice" , ventiPrice); item.put("ventiPrice" , ventiPrice);
priceList.add(ventiPrice);
} }
Collections.sort(priceList);
item.put("tallPrice" ,priceList.get(0));
List<JSONObject> dataList = new ArrayList<>(); List<JSONObject> dataList = new ArrayList<>();
JSONObject jsonObject ; JSONObject jsonObject ;

@ -57,6 +57,7 @@ public class OrderController {
@ApiOperation(value = "创建订单") @ApiOperation(value = "创建订单")
public ResponseData create(@RequestBody OrderModel body) { public ResponseData create(@RequestBody OrderModel body) {
try { try {
System.out.println("body" + body.toString());
// 用户session // 用户session
UserSessionObject userSession = userCenter.getSessionModel(UserSessionObject.class); UserSessionObject userSession = userCenter.getSessionModel(UserSessionObject.class);
if (userSession == null) { if (userSession == null) {
@ -86,6 +87,7 @@ public class OrderController {
body.setUserName(userSession.getUser().getName()); body.setUserName(userSession.getUser().getName());
body.setUserPhone(userSession.getUser().getPhone()); body.setUserPhone(userSession.getUser().getPhone());
return ResponseMsgUtil.success(orderService.create(body)); return ResponseMsgUtil.success(orderService.create(body));
} catch (Exception e) { } catch (Exception e) {

@ -1,18 +1,15 @@
package com.order.controller.business; package com.order.controller.business;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.hfkj.common.security.SessionObject;
import com.hfkj.common.security.UserCenter;
import com.hfkj.common.utils.PageUtil; import com.hfkj.common.utils.PageUtil;
import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.entity.BsOrderChild; import com.hfkj.entity.BsOrderChild;
import com.hfkj.entity.BsOrderStarbucks; import com.hfkj.entity.BsOrderStarbucks;
import com.hfkj.model.ResponseData; import com.hfkj.model.ResponseData;
import com.hfkj.model.SecUserSessionObject;
import com.hfkj.model.order.OrderStarbucksModel; import com.hfkj.model.order.OrderStarbucksModel;
import com.hfkj.service.goods.BsOrderStarbucksService; import com.hfkj.service.goods.BsOrderStarbucksService;
import com.hfkj.service.order.BsOrderChildService; import com.hfkj.service.order.BsOrderChildService;
import com.hfkj.sysenum.SecUserObjectTypeEnum;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -89,7 +86,7 @@ public class BsOrderStarbucksController {
starbucksModel.setStoreAddress(starbucks.get(0).getStoreAddress()); starbucksModel.setStoreAddress(starbucks.get(0).getStoreAddress());
starbucksModel.setStoreName(starbucks.get(0).getStoreName()); starbucksModel.setStoreName(starbucks.get(0).getStoreName());
starbucksModel.setUserPhone(starbucks.get(0).getUserPhone()); starbucksModel.setUserPhone(starbucks.get(0).getUserPhone());
starbucksModel.setPayType(starbucks.get(0).getPayType());
starbucksModelList.add(starbucksModel); starbucksModelList.add(starbucksModel);
} }

@ -36,36 +36,61 @@ public class StarbucksUtil {
for (String cup : cpuS) { for (String cup : cpuS) {
JSONObject obj = new JSONObject(); JSONObject obj = new JSONObject();
switch (cup) { if (cup.equals("中杯") && tallPrice.compareTo(new BigDecimal(1000)) < 0) {
case "中杯": obj.put("cpu" , "中杯");
obj.put("cpu", "中杯"); obj.put("notSelect" , tall);
obj.put("notSelect", tall); obj.put("select" , tallSelect);
obj.put("select", tallSelect); obj.put("volume" , "355ml");
obj.put("volume", "355ml"); obj.put("price", tallPrice);
obj.put("price", tallPrice); } else if (cup.equals("大杯") && grandePrice.compareTo(new BigDecimal(1000)) < 0) {
break; obj.put("cpu" , "大杯");
case "大杯": obj.put("notSelect" , grande);
obj.put("cpu", "大杯"); obj.put("select" , grandeSelect);
obj.put("notSelect", grande); obj.put("volume" , "473ml");
obj.put("select", grandeSelect); obj.put("price", grandePrice);
obj.put("volume", "473ml"); } else if (cup.equals("超大杯") && ventiPrice.compareTo(new BigDecimal(1000)) < 0) {
obj.put("price", grandePrice); obj.put("cpu" , "超大杯");
break; obj.put("notSelect" , venti);
case "超大杯": obj.put("select" , ventiSelect);
obj.put("cpu", "超大杯"); obj.put("volume" , "592ml");
obj.put("notSelect", venti); obj.put("price", ventiPrice);
obj.put("select", ventiSelect); } else {
obj.put("volume", "473ml"); obj.put("cpu" , "特殊杯");
obj.put("price", ventiPrice); obj.put("notSelect" , venti);
break; obj.put("select" , ventiSelect);
default: obj.put("volume" , "∞ml");
obj.put("cpu", "特殊杯"); obj.put("price", ventiPrice);
obj.put("notSelect", venti);
obj.put("select", ventiSelect);
obj.put("volume", "∞ml");
obj.put("price", ventiPrice);
break;
} }
// switch (cup) {
// case "中杯":
// obj.put("cpu", "中杯");
// obj.put("notSelect", tall);
// obj.put("select", tallSelect);
// obj.put("volume", "355ml");
// obj.put("price", tallPrice);
// break;
// case "大杯":
// obj.put("cpu", "大杯");
// obj.put("notSelect", grande);
// obj.put("select", grandeSelect);
// obj.put("volume", "473ml");
// obj.put("price", grandePrice);
// break;
// case "超大杯":
// obj.put("cpu", "超大杯");
// obj.put("notSelect", venti);
// obj.put("select", ventiSelect);
// obj.put("volume", "592ml");
// obj.put("price", ventiPrice);
// break;
// default:
// obj.put("cpu", "特殊杯");
// obj.put("notSelect", venti);
// obj.put("select", ventiSelect);
// obj.put("volume", "∞ml");
// obj.put("price", ventiPrice);
// break;
// }
list.add(obj); list.add(obj);
} }

@ -17,4 +17,6 @@ public class OrderStarbucksModel extends BsOrderChild{
private String storeName; private String storeName;
private String userPhone; private String userPhone;
private Integer payType;
} }

@ -103,14 +103,17 @@ public class StarbucksService {
* @Author: Sum1Dream * @Author: Sum1Dream
* @Date: 2024/8/1 下午2:21 * @Date: 2024/8/1 下午2:21
*/ */
public static JSONObject starbucksOrdersPay(Map<String , Object> map) throws Exception { public static JSONObject starbucksOrdersPay(Map<String , Object> map) {
try {
JSONObject object = QianZhuService.requestH5("starbucksOrders.pay" , map); JSONObject object = QianZhuService.requestH5("starbucksOrders.pay" , map);
if (object.getBoolean("success")) { if (object.getBoolean("success")) {
return object; return object;
} else { } else {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "查询失败!"); return null;
}
} catch (Exception e) {
return null;
} }
} }

@ -63,7 +63,7 @@ public class CmsContentServiceImpl implements CmsContentService {
if (StringUtils.isNotBlank(MapUtils.getString(map, "platformCode"))) { if (StringUtils.isNotBlank(MapUtils.getString(map, "platformCode"))) {
criteria.andPlatformCodeEqualTo(MapUtils.getString(map, "platformCode")); criteria.andPlatformCodeEqualTo(MapUtils.getString(map, "platformCode"));
} }
example.setOrderByClause("create_time desc");
return cmsContentMapper.selectByExample(example); return cmsContentMapper.selectByExample(example);
} }
} }

@ -361,7 +361,7 @@ public class OrderCreateService {
// 查询星巴克产品 // 查询星巴克产品
Map<String , Object> map = new HashMap<>(); Map<String , Object> map = new HashMap<>();
map.put("pageIndex", 1); map.put("pageIndex", 1);
map.put("pageSize", 100000); map.put("pageSize", 200);
JSONObject jsonObject = StarbucksService.starbucksProducts(map); JSONObject jsonObject = StarbucksService.starbucksProducts(map);
if (jsonObject.getJSONObject("data") == null) { if (jsonObject.getJSONObject("data") == null) {
throw ErrorHelp.genException(SysCode.System , ErrorCode.REQ_PARAMS_ERROR ); throw ErrorHelp.genException(SysCode.System , ErrorCode.REQ_PARAMS_ERROR );
@ -445,16 +445,16 @@ public class OrderCreateService {
orderChild.setMerId(productConfig.getMerId()); orderChild.setMerId(productConfig.getMerId());
orderChild.setProductName("星巴克"); orderChild.setProductName("星巴克");
orderChild.setProductCount(1); orderChild.setProductCount(1);
orderChild.setProductSpecName(String.valueOf(productSpecName.toString())); orderChild.setProductSpecName(productSpecName.toString());
// 星巴克创建订单 // 星巴克创建订单
// 获取token // 获取token
Map<String , Object> mapToken = new HashMap<>(); Map<String , Object> mapToken = new HashMap<>();
mapToken.put("platformUniqueId" , order.getOrderNo()); mapToken.put("platformUniqueId" , order.getOrderNo());
mapToken.put("nickname" , order.getUserName()); mapToken.put("nickname" , order.getUserName());
mapToken.put("mobile" , order.getUserPhone()); mapToken.put("mobile" , object.getString("phone"));
StarbucksService.getTokenV2(mapToken); StarbucksService.getTokenV2(mapToken);
// 查询产品 // 预下单
Map<String , Object> mapOrder = new HashMap<>(); Map<String , Object> mapOrder = new HashMap<>();
mapOrder.put("storeCode", object.getString("storeCode")); mapOrder.put("storeCode", object.getString("storeCode"));
mapOrder.put("customerMobile", object.getString("phone")); mapOrder.put("customerMobile", object.getString("phone"));

@ -76,7 +76,7 @@ public class OrderPaySuccessService {
} else if (childOrder.getProductType().equals(OrderChildProductTypeEnum.type3.getCode())) { } else if (childOrder.getProductType().equals(OrderChildProductTypeEnum.type3.getCode())) {
cinema(order, childOrder); cinema(order, childOrder);
} else if (childOrder.getProductType().equals(OrderChildProductTypeEnum.type4.getCode())) { } else if (childOrder.getProductType().equals(OrderChildProductTypeEnum.type4.getCode())) {
starbucks(childOrder); starbucks(order , childOrder);
} }
} catch (Exception e) { } catch (Exception e) {
@ -288,12 +288,21 @@ public class OrderPaySuccessService {
} }
public void starbucks(BsOrderChild childOrder) throws Exception { public void starbucks(OrderModel order,BsOrderChild childOrder) {
// 推送订单 // 推送订单
// 查询星巴克订单 // 查询星巴克订单
Map<String , Object> map = new HashMap<>(); Map<String , Object> map = new HashMap<>();
map.put("orderNo", childOrder.getChannelOrderNo()); map.put("orderNo", childOrder.getChannelOrderNo());
StarbucksService.starbucksOrdersPay(map); StarbucksService.starbucksOrdersPay(map);
Map<String, Object> params = new HashMap<>();
params.put("orderNo", childOrder.getOrderNo());
List<BsOrderStarbucks> orderStarbucks = bsOrderStarbucksService.getList(params);
for (BsOrderStarbucks bsOrderStarbucks : orderStarbucks) {
bsOrderStarbucks.setPayType(order.getPayType());
bsOrderStarbucksService.update(bsOrderStarbucks);
}
} }

@ -223,49 +223,64 @@ public class BsOrderServiceImpl implements BsOrderService {
BigDecimal payRealPrice = totalPrice.subtract(order.getDeduction().getTotalDeductionPrice()); BigDecimal payRealPrice = totalPrice.subtract(order.getDeduction().getTotalDeductionPrice());
order.setPayRealPrice(payRealPrice.compareTo(new BigDecimal("0")) > 0 ? payRealPrice : new BigDecimal("0")); order.setPayRealPrice(payRealPrice.compareTo(new BigDecimal("0")) > 0 ? payRealPrice : new BigDecimal("0"));
order.setOrderStatus(order.getPayRealPrice().compareTo(new BigDecimal("0")) == 0?OrderStatusEnum.status2.getCode():OrderStatusEnum.status1.getCode()); order.setOrderStatus(order.getPayRealPrice().compareTo(new BigDecimal("0")) == 0?OrderStatusEnum.status2.getCode():OrderStatusEnum.status1.getCode());
BigDecimal totalChildDiscountPrice = new BigDecimal("0");
Long totalIntegralDiscountPrice = 0L;
// 订单入库前处理 // 订单入库前处理
for (OrderChildModel childOrder : order.getOrderChildList()) { for (int i = 0; i < order.getOrderChildList().size();i++) {
OrderChildModel childOrder = order.getOrderChildList().get(i);
childOrder.setSurplusRefundCount(childOrder.getProductCount()); childOrder.setSurplusRefundCount(childOrder.getProductCount());
// 计算 子订单 在交易订单金额中的占比 // 计算 子订单 在交易订单金额中的占比
BigDecimal ratio = childOrder.getProductTotalPrice().divide(order.getTotalPrice(), 2, BigDecimal.ROUND_DOWN); BigDecimal ratio = childOrder.getProductTotalPrice().divide(order.getTotalPrice(), 2, BigDecimal.ROUND_DOWN);
// 计算子订单退款积分 // 优惠券优惠
if (order.getDeduction().getCouponDiscountActualPrice().compareTo(BigDecimal.ZERO) > 0) {
childOrder.setCouponDiscountPrice(order.getDeduction().getCouponDiscountActualPrice().multiply(ratio).setScale(2, BigDecimal.ROUND_DOWN));
} else {
childOrder.setCouponDiscountPrice(new BigDecimal("0"));
}
totalChildDiscountPrice = totalChildDiscountPrice.add(childOrder.getCouponDiscountPrice());
// 积分
if (order.getDeduction().getIntegralDiscountPrice() > 0) { if (order.getDeduction().getIntegralDiscountPrice() > 0) {
childOrder.setSurplusRefundIntegral(new BigDecimal(order.getDeduction().getIntegralDiscountPrice().toString()).multiply(ratio).setScale(2).longValue()); childOrder.setIntegralDiscountPrice(new BigDecimal(order.getDeduction().getIntegralDiscountPrice().toString()).multiply(ratio).setScale(2, BigDecimal.ROUND_DOWN).longValue());
} else { } else {
childOrder.setSurplusRefundIntegral(0L); childOrder.setIntegralDiscountPrice(0L);
} }
totalIntegralDiscountPrice = totalIntegralDiscountPrice + childOrder.getIntegralDiscountPrice();
// 如果是循环的最后一笔商品订单
if ((i+1) == order.getOrderChildList().size()) {
// 优惠券差值
BigDecimal couponDiscountDifference = order.getDeduction().getCouponDiscountActualPrice().subtract(totalChildDiscountPrice);
if (couponDiscountDifference.compareTo(BigDecimal.ZERO) > 0) {
// 大于0
childOrder.setCouponDiscountPrice(childOrder.getCouponDiscountPrice().add(couponDiscountDifference));
} else if (couponDiscountDifference.compareTo(BigDecimal.ZERO) < 0) {
// 小于0
childOrder.setCouponDiscountPrice(childOrder.getCouponDiscountPrice().subtract(couponDiscountDifference));
}
if (order.getDeduction().getCouponDiscountActualPrice().compareTo(BigDecimal.ZERO) == 1) { // 积分差值
// 计算子订单退款金额。 Long integralDiscountDifference = order.getDeduction().getIntegralDiscountPrice() - totalIntegralDiscountPrice;
if (order.getPayRealPrice().compareTo(BigDecimal.ZERO) == 1) { if (integralDiscountDifference > 0) {
// 计算实付金额中的占比 // 大于0
childOrder.setSurplusRefundPrice(order.getPayRealPrice().multiply(ratio).setScale(2, BigDecimal.ROUND_DOWN)); childOrder.setIntegralDiscountPrice(childOrder.getIntegralDiscountPrice() + integralDiscountDifference);
} else { } else if (integralDiscountDifference < 0) {
childOrder.setSurplusRefundPrice(new BigDecimal("0")); // 小于0
childOrder.setIntegralDiscountPrice(childOrder.getIntegralDiscountPrice() - integralDiscountDifference);
} }
} else {
childOrder.setSurplusRefundPrice(
// 商品总金额 - 积分抵扣金额
childOrder.getProductTotalPrice().subtract(
new BigDecimal(childOrder.getSurplusRefundIntegral().toString()).divide(new BigDecimal("100"))
));
} }
childOrder.setIntegralDiscountPrice(childOrder.getSurplusRefundIntegral()); // 商品订单总优惠
childOrder.setCouponDiscountPrice( childOrder.setTotalDeductionPrice(childOrder.getCouponDiscountPrice().add(new BigDecimal(childOrder.getIntegralDiscountPrice()).divide(new BigDecimal("100"))));
// 可退款金额大于0 可退款金额+可退款积分=优惠券优惠
childOrder.getSurplusRefundPrice().compareTo(BigDecimal.ZERO) == 1 // 可退款金额 产品总价 - 优惠总价
? childOrder.getProductTotalPrice().subtract( childOrder.setSurplusRefundPrice(childOrder.getProductTotalPrice().subtract(childOrder.getTotalDeductionPrice()));
childOrder.getSurplusRefundPrice().add(new BigDecimal(childOrder.getSurplusRefundIntegral().toString()).divide(new BigDecimal("100")))) // 可退款积分 积分优惠
: childOrder.getSurplusRefundPrice()); childOrder.setSurplusRefundIntegral(childOrder.getIntegralDiscountPrice());
// 商品实际价格
childOrder.setTotalDeductionPrice( childOrder.setProductActualPrice(childOrder.getSurplusRefundPrice());
childOrder.getCouponDiscountPrice()
.add(new BigDecimal(childOrder.getIntegralDiscountPrice().toString()).divide(new BigDecimal("100")))
);
childOrder.setProductActualPrice(childOrder.getProductTotalPrice().subtract(childOrder.getTotalDeductionPrice()));
orderChildService.editData(childOrder); orderChildService.editData(childOrder);
} }

@ -58,12 +58,12 @@ huiftShopCode=50041b27-f985-dcb0-1cc0-f106b09bf1fe
huiftSignSecret=DB4D8069A9AC6DDF9D75667EE5CF182A huiftSignSecret=DB4D8069A9AC6DDF9D75667EE5CF182A
#QIANZHU #QIANZHU
qianZhuUrl=https://live-test.qianzhu8.com qianZhuUrl=https://live.qianzhu8.com
qianzhuH5url=https://nf-test.qianzhu8.com/gateway qianzhuH5url=https://nf.qianzhu8.com/gateway
qinzhuUrlToken=https://live-test.qianzhu8.com/gateway qinzhuUrlToken=https://live.qianzhu8.com/gateway
qianZhuPlatformId=10376 qianZhuPlatformId=10710
qianZhuSecret=ktxb49sh2jfhgn8g qianZhuSecret=pgmh5j1cbq2brm08
qianZhuCinemaNotify=https://phgcs.dctpay.com/order/cinemaNotify/notify qianZhuCinemaNotify=https://phg.dctpay.com/order/cinemaNotify/notify
#CT #CT
ctNotifyUrl = 1 ctNotifyUrl = 1

Loading…
Cancel
Save