|
|
@ -24,6 +24,7 @@ import com.yxt.ordermall.api.shoppingcart.ShoppingCartQuery; |
|
|
|
import com.yxt.ordermall.api.shoppingcart.ShoppingCartVo; |
|
|
|
import com.yxt.ordermall.api.vegetablecellar.VegetableCellar; |
|
|
|
import com.yxt.ordermall.biz.appletgiftbag.AppletGiftBagService; |
|
|
|
import com.yxt.ordermall.biz.func.basegoodssku.GoodsSkuDetailVo; |
|
|
|
import com.yxt.ordermall.biz.lpkcustomer.LpkCustomerService; |
|
|
|
import com.yxt.ordermall.biz.lpkgoods.LpkGoodsService; |
|
|
|
import com.yxt.ordermall.biz.ordorderdetails.OrdOrderDetailService; |
|
|
@ -32,6 +33,7 @@ import com.yxt.ordermall.biz.shoppingcart.ShoppingCartService; |
|
|
|
import com.yxt.ordermall.biz.vegetablecellar.VegetableCellarService; |
|
|
|
import com.yxt.ordermall.biz.wx.RequestMes; |
|
|
|
import com.yxt.ordermall.biz.wx.WxConfig; |
|
|
|
import com.yxt.ordermall.feign.base.basegoodssku.BaseGoodsSkuFeign; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.http.ResponseEntity; |
|
|
@ -71,6 +73,8 @@ public class OrdOrderService extends MybatisBaseService<OrdOrderMapper, OrdOrder |
|
|
|
@Autowired |
|
|
|
RefundOrderMapper refundOrderMapper; |
|
|
|
@Autowired |
|
|
|
BaseGoodsSkuFeign baseGoodsSkuFeign; |
|
|
|
@Autowired |
|
|
|
VegetableCellarService vegetableCellarService; |
|
|
|
@Value("${weixin.miniprogram.appid:wx4724e3a3c27f36b5}") |
|
|
|
String appId; |
|
|
@ -187,12 +191,16 @@ public class OrdOrderService extends MybatisBaseService<OrdOrderMapper, OrdOrder |
|
|
|
for (ShoppingCartVo vo : vos) { |
|
|
|
OrdOrderDetailVo vo1 = new OrdOrderDetailVo(); |
|
|
|
LpkGoods goods = lpkGoodsService.getOne(new QueryWrapper<LpkGoods>().eq("sid", vo.getGoodsSid())); |
|
|
|
ResultBean<GoodsSkuDetailVo> goodsBySkuSid = baseGoodsSkuFeign.getGoodsBySkuSid(vo.getGoodsSid()); |
|
|
|
if(!goodsBySkuSid.getCode().equals("200")){ |
|
|
|
return goodsBySkuSid; |
|
|
|
} |
|
|
|
vo1.setGoodsSid(vo.getGoodsSid()); |
|
|
|
vo1.setGoodsName(vo.getGoodsName()); |
|
|
|
vo1.setPartNumber(Integer.parseInt(vo.getGoodsNumber())); |
|
|
|
vo1.setNumofPart(Double.valueOf(vo.getWeight())); |
|
|
|
vo1.setPriceUnit(Double.valueOf(goods.getPrice())); |
|
|
|
vo1.setPricePart((Double.valueOf(goods.getPrice()) * Double.valueOf(goods.getWeight()))); |
|
|
|
vo1.setPriceUnit(Double.valueOf(goodsBySkuSid.getData().getSalesPrice())); |
|
|
|
vo1.setPricePart(goodsBySkuSid.getData().getSPackPrice().doubleValue()); |
|
|
|
totalAmount = Double.valueOf(vo1.getPricePart()) * Double.valueOf(vo1.getPartNumber()) + totalAmount; |
|
|
|
ordOrderDetailVos.add(vo1); |
|
|
|
strings.add(vo.getSid()); |
|
|
@ -283,7 +291,125 @@ public class OrdOrderService extends MybatisBaseService<OrdOrderMapper, OrdOrder |
|
|
|
lpkCustomerService.updateById(customer); |
|
|
|
return rb.success().setData(result); |
|
|
|
} |
|
|
|
|
|
|
|
// @Transactional(rollbackFor = Exception.class)
|
|
|
|
// public ResultBean createVegeOrder(OrdOrderDto dto) {
|
|
|
|
// ResultBean rb = ResultBean.fireFail();
|
|
|
|
// PayResult result = new PayResult();
|
|
|
|
// if (StringUtils.isBlank(dto.getCustomerSid())) {
|
|
|
|
// return rb.setMsg("参数不全");
|
|
|
|
// }
|
|
|
|
// if (StringUtils.isBlank(dto.getBrandId())) {
|
|
|
|
// return rb.setMsg("参数不全");
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// List<OrdOrderDetailVo> ordOrderDetailVos = new ArrayList<>();
|
|
|
|
//
|
|
|
|
// ShoppingCartQuery query = new ShoppingCartQuery();
|
|
|
|
//
|
|
|
|
// query.setCustomerSid(dto.getCustomerSid());
|
|
|
|
// query.setBrandId(dto.getBrandId());
|
|
|
|
// List<ShoppingCartVo> vos = shoppingCartService.shoppingCartList(query).getData();
|
|
|
|
// List<String> strings = new ArrayList<>();
|
|
|
|
// double totalAmount = 0;
|
|
|
|
// for (ShoppingCartVo vo : vos) {
|
|
|
|
// OrdOrderDetailVo vo1 = new OrdOrderDetailVo();
|
|
|
|
// LpkGoods goods = lpkGoodsService.getOne(new QueryWrapper<LpkGoods>().eq("sid", vo.getGoodsSid()));
|
|
|
|
// vo1.setGoodsSid(vo.getGoodsSid());
|
|
|
|
// vo1.setGoodsName(vo.getGoodsName());
|
|
|
|
// vo1.setPartNumber(Integer.parseInt(vo.getGoodsNumber()));
|
|
|
|
// vo1.setNumofPart(Double.valueOf(vo.getWeight()));
|
|
|
|
// vo1.setPriceUnit(Double.valueOf(goods.getPrice()));
|
|
|
|
// vo1.setPricePart((Double.valueOf(goods.getPrice()) * Double.valueOf(goods.getWeight())));
|
|
|
|
// totalAmount = Double.valueOf(vo1.getPricePart()) * Double.valueOf(vo1.getPartNumber()) + totalAmount;
|
|
|
|
// ordOrderDetailVos.add(vo1);
|
|
|
|
// strings.add(vo.getSid());
|
|
|
|
// }
|
|
|
|
// dto.setOrdOrderDetailsVoList(ordOrderDetailVos);
|
|
|
|
// Map<String, Object> map = new HashMap<>();
|
|
|
|
// LpkCustomerVo vo = lpkCustomerService.getCustomerInfo(dto.getCustomerSid()).getData();
|
|
|
|
// Map<String, Object> sendBody = buildMessageBody(vo.getSid(), vo.getWxMpOpenid(), dto.getTotalTee(), dto.getOrdOrderDetailsVoList(), or);
|
|
|
|
// ResponseEntity<ResultBean> postForEntity = new RestTemplate().postForEntity("https://supervise.yxtsoft.com/wxPay/order/createOrder", sendBody, ResultBean.class);
|
|
|
|
//
|
|
|
|
// ResultBean<PayOrderVo> rb1 = postForEntity.getBody();
|
|
|
|
// LinkedHashMap rb2 = (LinkedHashMap) postForEntity.getBody().getData();
|
|
|
|
// if (!rb1.getCode().equals("200")) {
|
|
|
|
// return rb1;
|
|
|
|
// }
|
|
|
|
// OrdOrder order = new OrdOrder();
|
|
|
|
// BeanUtil.copyProperties(dto, order, "id", "sid");
|
|
|
|
// order.setCreateTime(new Date());
|
|
|
|
// order.setMainSid(rb2.get("mainSid").toString());
|
|
|
|
// order.setOutTradeNo(rb2.get("outTradeNo").toString());
|
|
|
|
// order.setPayStatus(2);
|
|
|
|
// order.setPayTime(new Date());
|
|
|
|
// order.setCardNumber(dto.getCardNumber());
|
|
|
|
// order.setSource(0);
|
|
|
|
// order.setUserSid(vo.getSid());
|
|
|
|
// order.setOpenId(vo.getWxMpOpenid());
|
|
|
|
// order.setTotalTee(dto.getTotalTee());//实付金额
|
|
|
|
// order.setMeet(removeZeros(String.valueOf(totalAmount)));//应付金额
|
|
|
|
// if (dto.getOrdOrderDetailsVoList().size() > 1) {
|
|
|
|
// order.setName(dto.getOrdOrderDetailsVoList().get(0).getGoodsName().toString() + "等" + (dto.getOrdOrderDetailsVoList().size()) + "件商品");
|
|
|
|
// } else {
|
|
|
|
// order.setName(dto.getOrdOrderDetailsVoList().get(0).getGoodsName().toString() + "商品");
|
|
|
|
// }
|
|
|
|
//// order.setName("商品");
|
|
|
|
// order.setTimeRemarks(10);
|
|
|
|
// order.setReturnUrl(or);
|
|
|
|
// baseMapper.insert(order);
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// List<OrdOrderDetail> ordOrders = new ArrayList<>();
|
|
|
|
// dto.getOrdOrderDetailsVoList().forEach(s -> {
|
|
|
|
// OrdOrderDetail ordOrderDetails = new OrdOrderDetail();
|
|
|
|
// BeanUtil.copyProperties(s, ordOrderDetails, "id", "sid");
|
|
|
|
// ordOrderDetails.setOrderSid(order.getSid());
|
|
|
|
// ordOrders.add(ordOrderDetails);
|
|
|
|
//
|
|
|
|
// });
|
|
|
|
// ordOrderDetailsService.saveBatch(ordOrders);
|
|
|
|
// //生成订单 删除购物车
|
|
|
|
// String[] sids = strings.toArray(new String[0]);
|
|
|
|
// shoppingCartService.delBySids(sids);
|
|
|
|
// if (dto.getOrdOrderDetailsVoList().size() > 1) {
|
|
|
|
// result.setGoods(dto.getOrdOrderDetailsVoList().get(0).getGoodsName().toString() + "等" + (dto.getOrdOrderDetailsVoList().size()) + "件商品");
|
|
|
|
// } else {
|
|
|
|
// result.setGoods(dto.getOrdOrderDetailsVoList().get(0).getGoodsName().toString() + "商品");
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// result.setPrice(dto.getTotalTee());
|
|
|
|
//// result.setOrderId(rbData.getOutTradeNo());
|
|
|
|
// result.setOrderId(rb2.get("outTradeNo").toString());
|
|
|
|
// result.setRemainder(String.valueOf(10 * 60));
|
|
|
|
//
|
|
|
|
// PayUrl payUrl = new PayUrl();
|
|
|
|
// payUrl.setUrl("https://supervise.yxtsoft.com/wxPay/order/pay");
|
|
|
|
// PayParams aVoid = new PayParams();
|
|
|
|
// aVoid.setMainSid(rb2.get("mainSid").toString());
|
|
|
|
// payUrl.setParams(aVoid);
|
|
|
|
//
|
|
|
|
// OrderUrl orderUrl = new OrderUrl();
|
|
|
|
// OrderParams orderParams = new OrderParams();
|
|
|
|
// orderParams.setMainSid("");
|
|
|
|
// orderUrl.setParams(orderParams);
|
|
|
|
//
|
|
|
|
// TradeNoUrl tradeNoUrl = new TradeNoUrl();
|
|
|
|
// tradeNoUrl.setUrl("https://supervise.yxtsoft.com/wxPay/order/orderQuery");
|
|
|
|
// TradeParams tradeParams = new TradeParams();
|
|
|
|
// tradeParams.setMainSid(rb2.get("mainSid").toString());
|
|
|
|
// tradeNoUrl.setParams(tradeParams);
|
|
|
|
//
|
|
|
|
//// result.setOrder_url(orderUrl);
|
|
|
|
// result.setPay_url(payUrl);
|
|
|
|
// result.setTrade_no_url(tradeNoUrl);
|
|
|
|
// String[] a = new String[]{"pay"};
|
|
|
|
// result.setBus(a);
|
|
|
|
// //新人限购礼包 该状态
|
|
|
|
// LpkCustomer customer = lpkCustomerService.getOne(new QueryWrapper<LpkCustomer>().eq("sid", dto.getCustomerSid()));
|
|
|
|
// customer.setIsPurchase("0");
|
|
|
|
// lpkCustomerService.updateById(customer);
|
|
|
|
// return rb.success().setData(result);
|
|
|
|
// }
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public ResultBean createNewUserBagOrder(OrdOrderDto dto) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|