|
|
@ -1,14 +1,21 @@ |
|
|
|
package com.yxt.yythmall.biz.ordorder; |
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.yxt.common.base.service.MybatisBaseService; |
|
|
|
import com.yxt.common.core.result.ResultBean; |
|
|
|
import com.yxt.yythmall.api.lpkcustomer.LpkCustomerVo; |
|
|
|
import com.yxt.yythmall.api.lpkgoods.LpkGoods; |
|
|
|
import com.yxt.yythmall.api.ordorder.*; |
|
|
|
import com.yxt.yythmall.api.ordorderdetails.OrdOrderDetail; |
|
|
|
import com.yxt.yythmall.api.ordorderdetails.OrdOrderDetailVo; |
|
|
|
import com.yxt.yythmall.api.shoppingcart.ShoppingCart; |
|
|
|
import com.yxt.yythmall.api.shoppingcart.ShoppingCartQuery; |
|
|
|
import com.yxt.yythmall.api.shoppingcart.ShoppingCartVo; |
|
|
|
import com.yxt.yythmall.biz.lpkcustomer.LpkCustomerService; |
|
|
|
import com.yxt.yythmall.biz.lpkgoods.LpkGoodsService; |
|
|
|
import com.yxt.yythmall.biz.ordorderdetails.OrdOrderDetailService; |
|
|
|
import com.yxt.yythmall.biz.shoppingcart.ShoppingCartService; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.http.ResponseEntity; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
@ -25,10 +32,15 @@ import java.util.*; |
|
|
|
public class OrdOrderService extends MybatisBaseService<OrdOrderMapper, OrdOrder> { |
|
|
|
|
|
|
|
private static final String OrderUrl="https://supervise.yxtsoft.com/lpkapi/empcardgift/generateTopEmpCard?mainSid="; |
|
|
|
private static final String or="https://supervise.yxtsoft.com/lpkapi/vegetablecellar/addGoods?mainSid="; |
|
|
|
@Autowired |
|
|
|
OrdOrderDetailService ordOrderDetailsService; |
|
|
|
@Autowired |
|
|
|
LpkCustomerService lpkCustomerService; |
|
|
|
@Autowired |
|
|
|
ShoppingCartService shoppingCartService; |
|
|
|
@Autowired |
|
|
|
LpkGoodsService lpkGoodsService; |
|
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@ -115,9 +127,28 @@ public class OrdOrderService extends MybatisBaseService<OrdOrderMapper, OrdOrder |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public ResultBean createVegeOrder(OrdOrderDto dto) { |
|
|
|
String or=""; |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
PayResult result=new PayResult(); |
|
|
|
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<>(); |
|
|
|
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()))); |
|
|
|
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); |
|
|
@ -139,7 +170,6 @@ public class OrdOrderService extends MybatisBaseService<OrdOrderMapper, OrdOrder |
|
|
|
order.setUserSid(vo.getSid()); |
|
|
|
order.setOpenId(vo.getWxMpOpenid()); |
|
|
|
order.setTotalTee(dto.getTotalTee()); |
|
|
|
order.setVegeCellarType(dto.getVegeCellarType()); |
|
|
|
if(dto.getOrdOrderDetailsVoList().size()>1){ |
|
|
|
order.setName(dto.getOrdOrderDetailsVoList().get(0).getGoodsName().toString()+"等"+(dto.getOrdOrderDetailsVoList().size()-1)+"件商品"); |
|
|
|
}else{ |
|
|
@ -160,6 +190,9 @@ public class OrdOrderService extends MybatisBaseService<OrdOrderMapper, OrdOrder |
|
|
|
|
|
|
|
}); |
|
|
|
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()-1)+"件商品"); |
|
|
|
}else{ |
|
|
@ -213,5 +246,23 @@ public class OrdOrderService extends MybatisBaseService<OrdOrderMapper, OrdOrder |
|
|
|
mp_template_msg.put("returnUrl", returnUrl); |
|
|
|
return mp_template_msg; |
|
|
|
} |
|
|
|
|
|
|
|
// private OrdOrderDto price(OrdOrderDto dto){
|
|
|
|
// int weight=0;
|
|
|
|
// for (OrdOrderDetailVo s : dto.getOrdOrderDetailsVoList()) {
|
|
|
|
// weight= (int) (s.getNumofPart()*s.getPartNumber()+weight);
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// if(weight>=20 && weight<=100){
|
|
|
|
// dto.setReceivablePrice(dto.getTotalTee());
|
|
|
|
// double a =1.1;
|
|
|
|
// dto.setTotalTee(String.valueOf(Double.valueOf(dto.getTotalTee())*a));
|
|
|
|
// }else if(weight>=101 && weight<=200){
|
|
|
|
// dto.setReceivablePrice(dto.getTotalTee());
|
|
|
|
// double a =1.05;
|
|
|
|
// dto.setTotalTee(String.valueOf(Double.valueOf(dto.getTotalTee())*a));
|
|
|
|
// }else {
|
|
|
|
// dto.setReceivablePrice(dto.getTotalTee());
|
|
|
|
// }
|
|
|
|
// return dto;
|
|
|
|
// }
|
|
|
|
} |
|
|
|