api需求上传

袁野 2 years ago
parent 40da39a651
commit 06e2a1402e
  1. 218
      hai-cweb/src/main/java/com/cweb/controller/HighThirdPartyController.java
  2. 37
      hai-service/src/main/java/com/hai/config/QianZhuConfig.java
  3. 80
      hai-service/src/main/java/com/hai/config/ThirdProductConfig.java
  4. 33
      hai-service/src/main/java/com/hai/entity/HighOrder.java
  5. 2
      hai-service/src/main/java/com/hai/service/HighOrderService.java
  6. 52
      hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java

@ -13,15 +13,14 @@ import com.hai.common.utils.CoordCommonUtil;
import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.ResponseMsgUtil;
import com.hai.config.CommonSysConst; import com.hai.config.CommonSysConst;
import com.hai.config.QianZhuConfig; import com.hai.config.QianZhuConfig;
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.ApiStarbucksProductsModel;
import com.hai.model.BsProductConfigModel; import com.hai.model.BsProductConfigModel;
import com.hai.model.HighUserModel; import com.hai.model.HighUserModel;
import com.hai.model.ResponseData; import com.hai.model.ResponseData;
import com.hai.service.ApiProductService; import com.hai.service.*;
import com.hai.service.BsConfigService;
import com.hai.service.HighOrderService;
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;
@ -37,6 +36,7 @@ import org.w3c.dom.ls.LSException;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -52,14 +52,23 @@ public class HighThirdPartyController {
private ApiProductService apiProductService; private ApiProductService apiProductService;
@Resource @Resource
private BsConfigService bsConfigService; private ThirdProductConfig thirdProductConfig;
@Resource @Resource
private HighOrderService highOrderService; private HighOrderService highOrderService;
@Resource
private BsCompanyService bsCompanyService;
@Resource
private CommonService commonService;
@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
@ -77,9 +86,22 @@ public class HighThirdPartyController {
@RequestMapping(value = "/getStarbucksProducts", method = RequestMethod.GET) @RequestMapping(value = "/getStarbucksProducts", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "查询星巴克商品") @ApiOperation(value = "查询星巴克商品")
public ResponseData getStarbucksProducts(@RequestParam(name = "name", required = false) String name) { public ResponseData getStarbucksProducts(@RequestParam(name = "name", required = false) String name,
@RequestParam(value = "regionId", required = true) String regionId) {
try { try {
SecRegion region = commonService.getParentByRegion(Long.valueOf(regionId));
BigDecimal productDiscount = null;
if (region != null) {
BsCompany bsCompany = bsCompanyService.selectCompanyByRegion(region.getRegionId().toString());
productDiscount = thirdProductConfig.getProductConfigNum(1, bsCompany.getId());
}
if (productDiscount == null) {
log.error("getRechargeProduct error!", "查询失败!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前地区未配置产品");
}
List<String> CategoryNameList = apiProductService.getCategoryName(); List<String> CategoryNameList = apiProductService.getCategoryName();
List<ApiStarbucksProducts> starbucksProductsList = new ArrayList<>(); List<ApiStarbucksProducts> starbucksProductsList = new ArrayList<>();
@ -88,11 +110,14 @@ public class HighThirdPartyController {
i++; i++;
ApiStarbucksProducts starbucksProducts = new ApiStarbucksProducts(); ApiStarbucksProducts starbucksProducts = new ApiStarbucksProducts();
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("name" , name); map.put("name", name);
map.put("categoryName" , s); map.put("categoryName", s);
List<ApiStarbucksProducts> list = apiProductService.getStarbucksProducts(map); List<ApiStarbucksProducts> list = apiProductService.getStarbucksProducts(map);
for (ApiStarbucksProducts apiStarbucksProducts : list) { for (ApiStarbucksProducts apiStarbucksProducts : list) {
apiStarbucksProducts.setExt1(String.valueOf(i)); apiStarbucksProducts.setExt1(String.valueOf(i));
apiStarbucksProducts.setSalesVentiPrice(apiStarbucksProducts.getSalesVentiPrice().add(apiStarbucksProducts.getSalesVentiPrice().multiply(productDiscount.divide(new BigDecimal(100)))).setScale(2, RoundingMode.HALF_UP));
apiStarbucksProducts.setSalesTallPrice(apiStarbucksProducts.getSalesTallPrice().add(apiStarbucksProducts.getSalesTallPrice().multiply(productDiscount.divide(new BigDecimal(100)))).setScale(2, RoundingMode.HALF_UP));
apiStarbucksProducts.setSalesGrandePrice(apiStarbucksProducts.getSalesGrandePrice().add(apiStarbucksProducts.getSalesGrandePrice().multiply(productDiscount.divide(new BigDecimal(100)))).setScale(2, RoundingMode.HALF_UP));
starbucksProductsList.add(apiStarbucksProducts); starbucksProductsList.add(apiStarbucksProducts);
} }
starbucksProducts.setName(s); starbucksProducts.setName(s);
@ -115,12 +140,12 @@ public class HighThirdPartyController {
public ResponseData getStarbucksStore(@RequestParam(name = "lat", required = true) String lat, public ResponseData getStarbucksStore(@RequestParam(name = "lat", required = true) String lat,
@RequestParam(name = "lon", required = true) String lon) { @RequestParam(name = "lon", required = true) String lon) {
try { try {
JSONObject jsonObject = QianZhuConfig.getStarbucksStore(lat , lon); JSONObject jsonObject = QianZhuConfig.getStarbucksStore(lat, lon);
if (jsonObject.getBoolean("success")) { if (jsonObject.getBoolean("success")) {
return ResponseMsgUtil.success(jsonObject.getJSONArray("data")); return ResponseMsgUtil.success(jsonObject.getJSONArray("data"));
} else { } else {
log.error("getRechargeProduct error!", "查询失败!"); log.error("getRechargeProduct error!", "查询失败!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR , jsonObject.getString("message")); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, jsonObject.getString("message"));
} }
} catch (Exception e) { } catch (Exception e) {
@ -129,77 +154,6 @@ public class HighThirdPartyController {
} }
} }
@RequestMapping(value = "/findStarbucksProducts", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "根据id查询详情产品详情")
public ResponseData findStarbucksProducts(@RequestParam(value = "id", required = true) Long id) {
try {
BsProductConfig bsProductConfig = apiProductService.findProductConfigByGoodsId(id);
if (bsProductConfig == null) {
log.error("findStarbucksProducts error!", "查询失败!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR , "未查询到当前商品");
}
ApiStarbucksProducts apiStarbucksProducts = apiProductService.findStarbucksProducts(bsProductConfig.getProductId());
apiStarbucksProducts.setSalesVentiPrice(apiStarbucksProducts.getMarketVentiPrice().multiply(bsProductConfig.getDiscount()).divide(new BigDecimal(100)));
apiStarbucksProducts.setSalesTallPrice(apiStarbucksProducts.getMarketTallPrice().multiply(bsProductConfig.getDiscount()).divide(new BigDecimal(100)));
apiStarbucksProducts.setSalesGrandePrice(apiStarbucksProducts.getMarketGrandePrice().multiply(bsProductConfig.getDiscount()).divide(new BigDecimal(100)));
ApiStarbucksProductsModel starbucksProductsModel = new ApiStarbucksProductsModel();
BeanUtils.copyProperties(apiStarbucksProducts, starbucksProductsModel);
Map<String, Object> listMap = new HashMap<>();
listMap.put("productType", "5");
listMap.put("returnType", 1);
listMap.put("sourceId", bsProductConfig.getId());
listMap.put("platformId", null);
starbucksProductsModel.setIntegralDiscount(bsConfigService.getProductDiscountByMap(listMap).getDiscount());
starbucksProductsModel.setProductPayTypeString(bsConfigService.getProductPayTypeByMap(listMap));
starbucksProductsModel.setProductPlatformString(bsConfigService.getProductPlatformByMap(listMap));
return ResponseMsgUtil.success(starbucksProductsModel);
} catch (Exception e) {
log.error("OutRechargePriceController --> findById() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/addOrder", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "增加订单")
public ResponseData addOrder(@RequestBody JSONObject object, HttpServletRequest request) {
try {
// 用户
SessionObject sessionObject = userCenter.getSessionObject(request);
HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject();
if (StringUtils.isBlank(object.getString("customerMobile")) ||
StringUtils.isBlank(object.getString("regionId")) ||
StringUtils.isBlank(object.getString("productType")) ||
object.getJSONArray("orderItems") == null
) {
log.error("addOrder error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
object.put("userId", userInfoModel.getHighUser().getId());
highOrderService.insertThirdProduct(object);
return ResponseMsgUtil.success("下单成功");
} catch (Exception e) {
log.error("HighOrderController -> addOrder() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/getKfcStoresList", method = RequestMethod.GET) @RequestMapping(value = "/getKfcStoresList", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ -207,19 +161,19 @@ public class HighThirdPartyController {
public ResponseData getKfcStoresList(@RequestParam(name = "storeName", required = false) String storeName, public ResponseData getKfcStoresList(@RequestParam(name = "storeName", required = false) String storeName,
@RequestParam(name = "cityCode", required = true) String cityCode, @RequestParam(name = "cityCode", required = true) String cityCode,
@RequestParam(name = "lat", required = true) String lat, @RequestParam(name = "lat", required = true) String lat,
@RequestParam(name = "lon", required = true) String lon) { @RequestParam(name = "lon", required = true) String lon) {
try { try {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("storeName" , storeName); map.put("storeName", storeName);
map.put("cityCode" , cityCode); map.put("cityCode", cityCode);
List<ApiKfcStores> list = apiProductService.getKfcStoresList(map); List<ApiKfcStores> list = apiProductService.getKfcStoresList(map);
if (StringUtils.isNotBlank(lat)){ if (StringUtils.isNotBlank(lat)) {
for (ApiKfcStores stores : list) { for (ApiKfcStores stores : list) {
double distance = CoordCommonUtil.getDistance(Double.valueOf(stores.getLat()), Double.valueOf(stores.getLon()), Double.valueOf(lat), Double.valueOf(lon)); double distance = CoordCommonUtil.getDistance(Double.valueOf(stores.getLat()), Double.valueOf(stores.getLon()), Double.valueOf(lat), Double.valueOf(lon));
stores.setDistance(String.valueOf(Math.round(distance/100d)/10d)); stores.setDistance(String.valueOf(Math.round(distance / 100d) / 10d));
} }
} }
@ -234,32 +188,46 @@ public class HighThirdPartyController {
@RequestMapping(value = "/listByStoreCode", method = RequestMethod.GET) @RequestMapping(value = "/listByStoreCode", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "查询肯德基门店菜单") @ApiOperation(value = "查询肯德基门店菜单")
public ResponseData listByStoreCode(@RequestParam(name = "storeCode", required = false) String storeCode) { public ResponseData listByStoreCode(@RequestParam(name = "storeCode", required = false) String storeCode, @RequestParam(value = "regionId", required = true) String regionId) {
try { try {
JSONObject jsonObject = QianZhuConfig.listByStoreCode(storeCode); JSONObject jsonObject = QianZhuConfig.listByStoreCode(storeCode);
JSONArray array = jsonObject.getJSONArray("data"); JSONArray array = jsonObject.getJSONArray("data");
Map<String, Object> listMap = new HashMap<>(); if (array == null) {
listMap.put("productType", "2"); log.error("addOrder error!");
listMap.put("companyId", 2); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未查询到任何门店");
}
BigDecimal productDiscount = null;
SecRegion region = commonService.getParentByRegion(Long.valueOf(regionId));
if (region != null) {
BsCompany bsCompany = bsCompanyService.selectCompanyByRegion(region.getRegionId().toString());
productDiscount = thirdProductConfig.getProductConfigNum(1, bsCompany.getId());
}
List<BsProductConfig> productConfigs = apiProductService.getProductConfig(listMap); if (productDiscount == null) {
log.error("getRechargeProduct error!", "查询失败!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前地区未配置产品");
}
int i = 0;
for (Object data : array) { for (Object data : array) {
JSONObject dataObject = (JSONObject) data; JSONObject dataObject = (JSONObject) data;
i++;
dataObject.put("kfcId", i);
if (dataObject.getJSONArray("products") != null) { if (dataObject.getJSONArray("products") != null) {
for (Object products : dataObject.getJSONArray("products")) { for (Object products : dataObject.getJSONArray("products")) {
JSONObject productsObject = (JSONObject) products; JSONObject productsObject = (JSONObject) products;
BigDecimal productsPrice = productsObject.getBigDecimal("price"); BigDecimal productsPrice = productsObject.getBigDecimal("price");
productsObject.put("salePrice" , productsPrice.add(productsPrice.multiply(productConfigs.get(0).getDiscount()).divide(new BigDecimal(100)))); productsObject.put("salePrice", productsPrice.add(productsPrice.multiply(productDiscount).divide(new BigDecimal(100))).setScale(2, RoundingMode.HALF_UP));
if (productsObject.getJSONArray("specGroups") != null) { if (productsObject.getJSONArray("specGroups") != null) {
for (Object specGroups : productsObject.getJSONArray("specGroups")) { for (Object specGroups : productsObject.getJSONArray("specGroups")) {
JSONObject specGroupsObject = (JSONObject) specGroups; JSONObject specGroupsObject = (JSONObject) specGroups;
BigDecimal specGroupsPrice = specGroupsObject.getBigDecimal("price"); BigDecimal specGroupsPrice = specGroupsObject.getBigDecimal("price");
specGroupsObject.put("salePrice" , specGroupsPrice.add(specGroupsPrice.multiply(productConfigs.get(0).getDiscount()).divide(new BigDecimal(100)))); specGroupsObject.put("salePrice", specGroupsPrice.add(specGroupsPrice.multiply(productDiscount).divide(new BigDecimal(100))).setScale(2, RoundingMode.HALF_UP));
} }
} }
} }
@ -270,12 +238,76 @@ public class HighThirdPartyController {
return ResponseMsgUtil.success(array); return ResponseMsgUtil.success(array);
} else { } else {
log.error("getRechargeProduct error!", "查询失败!"); log.error("getRechargeProduct error!", "查询失败!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR , jsonObject.getString("message")); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, jsonObject.getString("message"));
}
} catch (Exception e) {
log.error("HighUserCardController --> oilCardRefund() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/getThirdPartyByDetail", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询第三方产品详情")
public ResponseData getThirdPartyByDetail(@RequestParam(name = "platformId", required = true) Integer platformId,
@RequestParam(name = "productType", required = true) Integer productType,
@RequestParam(name = "regionId", required = true) String regionId) {
try {
SecRegion region = commonService.getParentByRegion(Long.valueOf(regionId));
if (region == null) {
log.error("getRechargeProduct error!", "查询失败!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, regionId + "当前地区未配置产品");
} }
BsCompany bsCompany = bsCompanyService.selectCompanyByRegion(region.getRegionId().toString());
return ResponseMsgUtil.success(thirdProductConfig.getThirdPartyByDetail(platformId , productType , bsCompany.getId()));
} catch (Exception e) { } catch (Exception e) {
log.error("HighUserCardController --> oilCardRefund() error!", e); log.error("HighUserCardController --> oilCardRefund() error!", e);
return ResponseMsgUtil.exception(e); return ResponseMsgUtil.exception(e);
} }
} }
@RequestMapping(value = "/addOrder", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "增加订单")
public ResponseData addOrder(@RequestBody JSONObject object, HttpServletRequest request) {
try {
// 用户
SessionObject sessionObject = userCenter.getSessionObject(request);
HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject();
if (StringUtils.isBlank(object.getString("customerMobile")) ||
StringUtils.isBlank(object.getString("regionId")) ||
StringUtils.isBlank(object.getString("storeCode")) ||
object.getInteger("productType") == null ||
object.getInteger("platformId") == null ||
object.getJSONArray("orderItems") == null
) {
log.error("addOrder error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
SecRegion region = commonService.getParentByRegion(object.getLong("regionId"));
if (region != null) {
BsCompany bsCompany = bsCompanyService.selectCompanyByRegion(region.getRegionId().toString());
object.put("companyId", String.valueOf(bsCompany.getId()));
}
object.put("userId", userInfoModel.getHighUser().getId());
return ResponseMsgUtil.success(highOrderService.insertThirdProduct(object));
} catch (Exception e) {
log.error("HighOrderController -> addOrder() error!", e);
return ResponseMsgUtil.exception(e);
}
}
} }

@ -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( String platformUniqueId ,String storeCode , String orderItems , String customerMobile) throws Exception { public static JSONObject starbucksOrders( Long 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);
@ -338,7 +338,7 @@ public class QianZhuConfig {
Map<String,Object> contentMap = new LinkedHashMap<>(); Map<String,Object> contentMap = new LinkedHashMap<>();
contentMap.put("orderNo", orderNo); contentMap.put("orderNo", orderNo);
Map<String,Object> map = new HashMap<>(); Map<String,Object> map = new HashMap<>();
map.put("platformId", "10458"); map.put("platformId", CommonSysConst.getSysConfig().getQinzhuPlatformId());
map.put("action", "starbucksOrders.pay"); map.put("action", "starbucksOrders.pay");
map.put("version", "1.0"); map.put("version", "1.0");
map.put("content", JSON.toJSONString(contentMap)); map.put("content", JSON.toJSONString(contentMap));
@ -369,4 +369,37 @@ public class QianZhuConfig {
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));
} }
/**
* @Author Sum1Dream
* @name starbucksOrderByOrderNo.java
* @Description // 根据订单号查询星巴克订单详情
* @Date 16:38 2022/7/5
* @Param [java.lang.String]
* @return com.alibaba.fastjson.JSONObject
*/
public static JSONObject starbucksOrderByOrderNo(String orderNo) throws Exception {
Map<String,Object> contentMap = new LinkedHashMap<>();
contentMap.put("orderNo", orderNo);
Map<String,Object> map = new HashMap<>();
map.put("platformId", CommonSysConst.getSysConfig().getQinzhuPlatformId());
map.put("action", "starbucksOrders.getByOrderNo");
map.put("version", "1.0");
map.put("content", JSON.toJSONString(contentMap));
map.put("traceId", WxUtils.makeNonStr());
map.put("timestamp", new Date().getTime());
map.put("sign", MD5Util.encode(generateSignature(map,"nnl3gg4ss0pka11t").getBytes()).toLowerCase());
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 {
Map<String,Object> map = new HashMap<>();
map.put("platformId", CommonSysConst.getSysConfig().getQinzhuPlatformId());
map.put("items", items);
map.put("timestamp", new Date().getTime());
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));
}
} }

@ -0,0 +1,80 @@
package com.hai.config;
import com.alibaba.fastjson.JSONObject;
import com.hai.entity.BsProductConfig;
import com.hai.entity.BsProductDiscount;
import com.hai.service.ApiProductService;
import com.hai.service.BsConfigService;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author hurui
* @version 1.0
* @ClassName ThirdProductConfig
* @description: 第三方接口配置文件
* @date 2021/7/5 14:18
*/
@Component
public class ThirdProductConfig {
@Resource
private BsConfigService bsConfigService;
@Resource
private ApiProductService apiProductService;
// 产品折扣比例
public BigDecimal getProductConfigNum(Integer productType , Long companyId) {
Map<String, Object> listMap = new HashMap<>();
listMap.put("productType", productType);
listMap.put("companyId", companyId);
List<BsProductConfig> productConfigs = apiProductService.getProductConfig(listMap);
if (productConfigs.size() > 0 ) {
return productConfigs.get(0).getDiscount();
}
return null;
}
// 产品折扣比例
public BsProductConfig getProductConfig(Integer productType , Long companyId) {
Map<String, Object> listMap = new HashMap<>();
listMap.put("productType", productType);
listMap.put("companyId", companyId);
List<BsProductConfig> productConfigs = apiProductService.getProductConfig(listMap);
if (productConfigs.size() > 0 ) {
return productConfigs.get(0);
}
return null;
}
public JSONObject getThirdPartyByDetail(Integer platformId , Integer productType , Long companyId) {
BsProductConfig productConfig = getProductConfig(productType, companyId);
JSONObject object = new JSONObject();
Map<String, Object> listMap = new HashMap<>();
listMap.put("productType", "5");
listMap.put("returnType", 1);
listMap.put("sourceId", productConfig.getId());
listMap.put("platformId", platformId);
object.put("integralDiscount" , bsConfigService.getProductDiscountByMap(listMap).getDiscount());
object.put("productPayType" , bsConfigService.getProductPayTypeByMap(listMap));
object.put("productPlatform" , bsConfigService.getProductPlatformByMap(listMap));
return object;
}
}

@ -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
@ -200,6 +201,36 @@ 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() {
@ -662,4 +693,4 @@ public class HighOrder implements Serializable {
sb.append("]"); sb.append("]");
return sb.toString(); return sb.toString();
} }
} }

@ -443,5 +443,5 @@ public interface HighOrderService {
* @Param [com.alibaba.fastjson.JSONObject] * @Param [com.alibaba.fastjson.JSONObject]
* @return void * @return void
*/ */
void insertThirdProduct(JSONObject object); JSONObject insertThirdProduct(JSONObject object) throws Exception;
} }

@ -8,6 +8,7 @@ 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.utils.DateUtil;
import com.hai.common.utils.HttpsUtils; import com.hai.common.utils.HttpsUtils;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.config.*; import com.hai.config.*;
import com.hai.dao.*; import com.hai.dao.*;
import com.hai.entity.*; import com.hai.entity.*;
@ -15,6 +16,7 @@ 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 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.eclipse.paho.client.mqttv3.MqttClient; import org.eclipse.paho.client.mqttv3.MqttClient;
@ -43,6 +45,9 @@ public class HighOrderServiceImpl implements HighOrderService {
@Resource @Resource
private HighDeviceService deviceService; private HighDeviceService deviceService;
@Resource
private ThirdProductConfig thirdProductConfig;
@Resource @Resource
private HighOrderMapperExt highOrderMapperExt; private HighOrderMapperExt highOrderMapperExt;
@ -55,6 +60,10 @@ public class HighOrderServiceImpl implements HighOrderService {
@Resource @Resource
private HighCouponCodeService highCouponCodeService; private HighCouponCodeService highCouponCodeService;
@Resource
private ApiProductService apiProductService;
@Resource @Resource
private HighCouponService highCouponService; private HighCouponService highCouponService;
@ -1763,21 +1772,40 @@ public class HighOrderServiceImpl implements HighOrderService {
} }
} }
@Override public JSONObject insertThirdProduct(JSONObject object) throws Exception {
@Transactional(
isolation = Isolation.SERIALIZABLE, HighOrder highOrder = new HighOrder();
propagation = Propagation.REQUIRES_NEW)
public void insertThirdProduct(JSONObject object) {
HighUser user = highUserService.findByUserId(object.getLong("userId")); HighUser user = highUserService.findByUserId(object.getLong("userId"));
// 查询积分抵扣比例 JSONObject jsonObject = null;
Map<String, Object> listMap = new HashMap<>(); // 1 星巴克 2 肯德基
listMap.put("productType", "5"); if (object.getInteger("productType") == 1) {
listMap.put("returnType", 1); jsonObject = QianZhuConfig.starbucksOrders(object.getLong("userId") , object.getString("storeCode") , object.getString("orderItems") , object.getString("customerMobile"));
listMap.put("sourceId", 100001); } else if (object.getInteger("productType") == 2) {
if (object.getInteger("eatType") == null) {
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"));
}
if (jsonObject != null && jsonObject.getBoolean("success")) {
highOrder.setOrderNo(jsonObject.getJSONObject("data").getString("orderNo"));
highOrder.setRegionId(object.getString("regionId"));
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);
BsProductDiscount bsProductDiscount = bsConfigService.getProductDiscountByMap(listMap);
return jsonObject.getJSONObject("data");
} else {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR , jsonObject.getString("message"));
}
} }
} }

Loading…
Cancel
Save