|
|
|
@ -1,5 +1,6 @@ |
|
|
|
|
package com.order.controller; |
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
@ -11,22 +12,23 @@ import com.hfkj.common.utils.PageUtil; |
|
|
|
|
import com.hfkj.common.utils.ResponseMsgUtil; |
|
|
|
|
import com.hfkj.common.utils.SignatureUtil; |
|
|
|
|
import com.hfkj.config.CommonSysConst; |
|
|
|
|
import com.hfkj.entity.BsOrder; |
|
|
|
|
import com.hfkj.entity.BsOrderChild; |
|
|
|
|
import com.hfkj.entity.BsOrderGoods; |
|
|
|
|
import com.hfkj.entity.GoodsSpecs; |
|
|
|
|
import com.hfkj.entity.*; |
|
|
|
|
import com.hfkj.haioil.HaiOilService; |
|
|
|
|
import com.hfkj.jd.JdPostService; |
|
|
|
|
import com.hfkj.jd.JdService; |
|
|
|
|
import com.hfkj.model.ResponseData; |
|
|
|
|
import com.hfkj.model.UserSessionObject; |
|
|
|
|
import com.hfkj.model.order.OrderChildModel; |
|
|
|
|
import com.hfkj.model.order.OrderModel; |
|
|
|
|
import com.hfkj.service.goods.BsOrderGoodsService; |
|
|
|
|
import com.hfkj.service.goods.GoodsSpecsService; |
|
|
|
|
import com.hfkj.service.goods.GoodsUserAddressService; |
|
|
|
|
import com.hfkj.service.order.BsOrderService; |
|
|
|
|
import com.hfkj.service.order.impl.BsOrderChildServiceImpl; |
|
|
|
|
import com.hfkj.service.pay.HuiPayService; |
|
|
|
|
import com.hfkj.sysenum.UserStatusEnum; |
|
|
|
|
import com.hfkj.sysenum.order.*; |
|
|
|
|
import com.jd.open.api.sdk.response.vopdz.VopAddressConvertFourAreaByDetailStrResponse; |
|
|
|
|
import io.swagger.annotations.Api; |
|
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
@ -62,7 +64,12 @@ public class OrderController { |
|
|
|
|
private GoodsSpecsService goodsSpecsService; |
|
|
|
|
@Resource |
|
|
|
|
private BsOrderGoodsService orderGoodsService; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private JdService jdService; |
|
|
|
|
@Resource |
|
|
|
|
private GoodsUserAddressService goodsUserAddressService; |
|
|
|
|
@Resource |
|
|
|
|
private GoodsUserAddressService deliveryAddressService; |
|
|
|
|
@RequestMapping(value="/create",method = RequestMethod.POST) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "创建订单") |
|
|
|
@ -340,4 +347,65 @@ public class OrderController { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@RequestMapping(value="/querySkuFreight",method = RequestMethod.POST) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "查询运费") |
|
|
|
|
public ResponseData querySkuFreight(@RequestBody JSONObject body) { |
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
if (body == null || |
|
|
|
|
body.getJSONArray("skuInfoList") == null |
|
|
|
|
|| body.getLong("addressId") == null |
|
|
|
|
) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
JSONArray array = body.getJSONArray("skuInfoList"); |
|
|
|
|
GoodsUserAddress userAddress = goodsUserAddressService.queryDetail(body.getLong("addressId")); |
|
|
|
|
|
|
|
|
|
if (userAddress.getProvinceId() == null) { |
|
|
|
|
VopAddressConvertFourAreaByDetailStrResponse response = JdPostService.convertFourAreaByDetailStr(jdService.getToken() , userAddress.getRegionName() + userAddress.getAddress()); |
|
|
|
|
|
|
|
|
|
if (response != null && response.getOpenRpcResult().getSuccess()) { |
|
|
|
|
userAddress.setProvinceId(response.getOpenRpcResult().getResult().getProvinceId()); |
|
|
|
|
userAddress.setProvinceName(response.getOpenRpcResult().getResult().getProvinceName()); |
|
|
|
|
userAddress.setCityId(response.getOpenRpcResult().getResult().getCityId()); |
|
|
|
|
userAddress.setCityName(response.getOpenRpcResult().getResult().getCityName()); |
|
|
|
|
userAddress.setCountyId(response.getOpenRpcResult().getResult().getCountyId()); |
|
|
|
|
userAddress.setCountyName(response.getOpenRpcResult().getResult().getCountyName()); |
|
|
|
|
userAddress.setTownId(response.getOpenRpcResult().getResult().getTownId()); |
|
|
|
|
userAddress.setTownName(response.getOpenRpcResult().getResult().getTownName()); |
|
|
|
|
userAddress.setUpdateTime(new Date()); |
|
|
|
|
deliveryAddressService.update(userAddress); |
|
|
|
|
} else { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, response.getOpenRpcResult().getResultMessage()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
List<com.jd.open.api.sdk.domain.vopdd.QueryOrderOpenProvider.request.querySkuFreight.SkuInfoOrderOpenReq> skuInfoList = new ArrayList<>(); |
|
|
|
|
com.jd.open.api.sdk.domain.vopdd.QueryOrderOpenProvider.request.querySkuFreight.SkuInfoOrderOpenReq skuInfo = new com.jd.open.api.sdk.domain.vopdd.QueryOrderOpenProvider.request.querySkuFreight.SkuInfoOrderOpenReq(); |
|
|
|
|
|
|
|
|
|
for(Object object : array) { |
|
|
|
|
JSONObject json = (JSONObject)object; |
|
|
|
|
GoodsSpecs specs = goodsSpecsService.queryDetail(json.getLong("specsId")); |
|
|
|
|
if (specs.getThirdId() != null) { |
|
|
|
|
skuInfo.setSkuId(Long.parseLong(specs.getThirdId())); |
|
|
|
|
skuInfo.setSkuNum(json.getInteger("num")); |
|
|
|
|
skuInfoList.add(skuInfo); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (skuInfoList.isEmpty()) { |
|
|
|
|
JSONObject object = new JSONObject(); |
|
|
|
|
object.put("totalFreight" , 0); |
|
|
|
|
return ResponseMsgUtil.success(object); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success(JdPostService.querySkuFreight(jdService.getToken() , skuInfoList , userAddress.getProvinceId() ,userAddress.getCityId() , userAddress.getCountyId() , userAddress.getTownId()).getOpenRpcResult().getResult()); |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("error!",e); |
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|