|
|
|
@ -1,22 +1,30 @@ |
|
|
|
|
package org.jeecg.modules.demo.zyorders.controller; |
|
|
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
|
|
import java.util.Date; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.io.UnsupportedEncodingException; |
|
|
|
|
import java.net.URLDecoder; |
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
|
|
|
|
|
import org.apache.shiro.SecurityUtils; |
|
|
|
|
import org.jeecg.common.api.vo.Result; |
|
|
|
|
import org.jeecg.common.system.query.QueryGenerator; |
|
|
|
|
import org.jeecg.common.system.vo.LoginUser; |
|
|
|
|
import org.jeecg.common.util.oConvertUtils; |
|
|
|
|
import org.jeecg.modules.demo.accessories.service.IZyAccessoriesService; |
|
|
|
|
import org.jeecg.modules.demo.base.service.IZyClothsTypeService; |
|
|
|
|
import org.jeecg.modules.demo.customerinvoice.entity.CustomerInvoice; |
|
|
|
|
import org.jeecg.modules.demo.customerinvoice.service.ICustomerInvoiceService; |
|
|
|
|
import org.jeecg.modules.demo.customermeasure.entity.CustomerMeasure; |
|
|
|
|
import org.jeecg.modules.demo.customermeasure.service.ICustomerMeasureService; |
|
|
|
|
import org.jeecg.modules.demo.customerpayment.entity.CustomerPayment; |
|
|
|
|
import org.jeecg.modules.demo.customerpayment.service.ICustomerPaymentService; |
|
|
|
|
import org.jeecg.modules.demo.customerreceivingaddress.entity.CustomerReceivingAddress; |
|
|
|
|
import org.jeecg.modules.demo.customerreceivingaddress.service.ICustomerReceivingAddressService; |
|
|
|
|
import org.jeecg.modules.demo.fabric.service.IZyFabricService; |
|
|
|
|
import org.jeecg.modules.demo.goodsaccessories.entity.GoodsAccessories; |
|
|
|
|
import org.jeecg.modules.demo.goodsaccessories.service.IGoodsAccessoriesService; |
|
|
|
|
import org.jeecg.modules.demo.goodsfabric.entity.GoodsFabric; |
|
|
|
@ -34,6 +42,9 @@ import org.jeecg.modules.demo.ordergoodsmodule.entity.OrderGoodsModule; |
|
|
|
|
import org.jeecg.modules.demo.ordergoodsmodule.service.IOrderGoodsModuleService; |
|
|
|
|
import org.jeecg.modules.demo.zyaccessories.entity.ZyStyleAccessories; |
|
|
|
|
import org.jeecg.modules.demo.zyaccessories.service.IZyStyleAccessoriesService; |
|
|
|
|
import org.jeecg.modules.demo.zygoods.entity.Dz; |
|
|
|
|
import org.jeecg.modules.demo.zygoods.entity.FzlxSp; |
|
|
|
|
import org.jeecg.modules.demo.zygoods.entity.Tcsp; |
|
|
|
|
import org.jeecg.modules.demo.zygoods.entity.ZyGoods; |
|
|
|
|
import org.jeecg.modules.demo.zygoods.service.IZyGoodsService; |
|
|
|
|
import org.jeecg.modules.demo.zyorders.entity.ZyOrders; |
|
|
|
@ -45,6 +56,11 @@ import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
|
|
|
|
import org.jeecg.modules.system.entity.SysDepart; |
|
|
|
|
import org.jeecg.modules.system.entity.SysUser; |
|
|
|
|
import org.jeecg.modules.system.service.ISysDepartService; |
|
|
|
|
import org.jeecg.modules.system.service.ISysUserService; |
|
|
|
|
import org.jeecg.modules.zyclothsstyle.service.IZyClothsStyleService; |
|
|
|
|
import org.jeecg.modules.zystylefabric.entity.ZyStyleFabric; |
|
|
|
|
import org.jeecg.modules.zystylefabric.service.IZyStyleFabricService; |
|
|
|
|
import org.jeecg.modules.zystylemodule.entity.ZyStyleModule; |
|
|
|
@ -85,6 +101,8 @@ public class ZyOrdersController extends JeecgController<ZyOrders, IZyOrdersServi |
|
|
|
|
@Autowired |
|
|
|
|
private ICustomerInvoiceService iCustomerInvoiceService; |
|
|
|
|
@Autowired |
|
|
|
|
private ICustomerPaymentService iCustomerPaymentService; |
|
|
|
|
@Autowired |
|
|
|
|
private IZyGoodsService zyGoodsService; |
|
|
|
|
@Autowired |
|
|
|
|
private IOrderGoodsModuleService orderGoodsModuleService; |
|
|
|
@ -98,6 +116,19 @@ public class ZyOrdersController extends JeecgController<ZyOrders, IZyOrdersServi |
|
|
|
|
private IGoodsFabricService goodsFabricService; |
|
|
|
|
@Autowired |
|
|
|
|
private IGoodsAccessoriesService goodsAccessoriesService; |
|
|
|
|
@Autowired |
|
|
|
|
private IZyClothsStyleService zyClothsStyleService; |
|
|
|
|
@Autowired |
|
|
|
|
private IZyFabricService zyFabricService; |
|
|
|
|
@Autowired |
|
|
|
|
private IZyAccessoriesService zyAccessoriesService; |
|
|
|
|
@Autowired |
|
|
|
|
private ISysDepartService sysDepartService; |
|
|
|
|
@Autowired |
|
|
|
|
private ISysUserService sysUserService; |
|
|
|
|
@Autowired |
|
|
|
|
private ICustomerMeasureService iCustomerMeasureService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 订单和订单商品接口 |
|
|
|
@ -430,4 +461,303 @@ public class ZyOrdersController extends JeecgController<ZyOrders, IZyOrdersServi |
|
|
|
|
return super.importExcel(request, response, ZyOrders.class); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 商城接口下单 |
|
|
|
|
* |
|
|
|
|
* @param req |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@AutoLog(value = "下单") |
|
|
|
|
@ApiOperation(value="下单", notes="下单") |
|
|
|
|
@GetMapping(value = "/xd") |
|
|
|
|
public Result<?> xd(@RequestParam(name="goodsid",required=true) String goodsid,HttpServletRequest req) { |
|
|
|
|
//这里方便获取当前登陆信息
|
|
|
|
|
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
|
|
|
|
//这里获取当前登陆的id
|
|
|
|
|
String userid = loginUser.getId(); |
|
|
|
|
//这里获取当前登陆的真实姓名
|
|
|
|
|
String rlname = loginUser.getRealname(); |
|
|
|
|
ZyGoods zyGoods = zyGoodsService.getById(goodsid); |
|
|
|
|
Map<String,Object> map = new HashMap<>(); |
|
|
|
|
Date d = new Date(); |
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
|
map.put("dqsj",sdf.format(d)); |
|
|
|
|
map.put("orderNum",getOrdersNum()); |
|
|
|
|
//默认地址
|
|
|
|
|
CustomerReceivingAddress customerReceivingAddress = new CustomerReceivingAddress(); |
|
|
|
|
QueryWrapper<CustomerReceivingAddress> queryWrappercra = QueryGenerator.initQueryWrapper(customerReceivingAddress, req.getParameterMap()); |
|
|
|
|
queryWrappercra.eq("user_id",userid); |
|
|
|
|
queryWrappercra.orderByAsc("sort"); |
|
|
|
|
List<CustomerReceivingAddress> listcra = iCustomerReceivingAddressService.list(queryWrappercra); |
|
|
|
|
Dz dz = new Dz(); |
|
|
|
|
dz.setId(listcra.get(0).getId()); |
|
|
|
|
dz.setAddr1(listcra.get(0).getCityId()); |
|
|
|
|
dz.setAddr2(listcra.get(0).getAddress()); |
|
|
|
|
dz.setPostCode(listcra.get(0).getZipCode()); |
|
|
|
|
dz.setFlag(false); |
|
|
|
|
map.put("address",dz); |
|
|
|
|
map.put("gmr",rlname); |
|
|
|
|
map.put("spmc",zyGoods.getGoodsName()); |
|
|
|
|
map.put("spjg",zyGoods.getUnitPrice()); |
|
|
|
|
map.put("spks",zyClothsStyleService.getById(zyGoods.getStyleId()).getStyleNames()); |
|
|
|
|
//主辅料
|
|
|
|
|
GoodsFabric goodsFabric = new GoodsFabric(); |
|
|
|
|
QueryWrapper<GoodsFabric> queryWrappergf = QueryGenerator.initQueryWrapper(goodsFabric, req.getParameterMap()); |
|
|
|
|
queryWrappergf.eq("goods_id",goodsid); |
|
|
|
|
List<GoodsFabric> listgf = goodsFabricService.list(queryWrappergf); |
|
|
|
|
String zlstr = ""; |
|
|
|
|
for(int i = 0 ; i < listgf.size() ; i++){ |
|
|
|
|
zlstr = zlstr + zyFabricService.getById(listgf.get(i).getFabricId()).getName()+","; |
|
|
|
|
} |
|
|
|
|
GoodsAccessories goodsAccessories = new GoodsAccessories(); |
|
|
|
|
QueryWrapper<GoodsAccessories> queryWrapperga = QueryGenerator.initQueryWrapper(goodsAccessories, req.getParameterMap()); |
|
|
|
|
queryWrapperga.eq("goods_id",goodsid); |
|
|
|
|
List<GoodsAccessories> listga = goodsAccessoriesService.list(queryWrapperga); |
|
|
|
|
String flstr = ""; |
|
|
|
|
for(int k = 0 ; k < listga.size() ; k++){ |
|
|
|
|
flstr = flstr + zyAccessoriesService.getById(listga.get(k).getAccessoriesId()).getContents()+","; |
|
|
|
|
} |
|
|
|
|
map.put("zfl",zlstr+flstr.substring(0,flstr.length()-1)); |
|
|
|
|
map.put("sptp","http://localhost:10085/jeecg-boot/sys/common/static/"+zyGoods.getDefaultPicture()); |
|
|
|
|
return Result.OK(map); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 获取地址列表 |
|
|
|
|
* |
|
|
|
|
* @param req |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@AutoLog(value = "地址列表") |
|
|
|
|
@ApiOperation(value="地址列表", notes="地址列表") |
|
|
|
|
@GetMapping(value = "/dzlist") |
|
|
|
|
public Result<?> dzlist(HttpServletRequest req) { |
|
|
|
|
//这里方便获取当前登陆信息
|
|
|
|
|
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
|
|
|
|
//这里获取当前登陆的id
|
|
|
|
|
String userid = loginUser.getId(); |
|
|
|
|
CustomerReceivingAddress customerReceivingAddress = new CustomerReceivingAddress(); |
|
|
|
|
QueryWrapper<CustomerReceivingAddress> queryWrappercra = QueryGenerator.initQueryWrapper(customerReceivingAddress, req.getParameterMap()); |
|
|
|
|
queryWrappercra.eq("user_id",userid); |
|
|
|
|
List<CustomerReceivingAddress> listcra = iCustomerReceivingAddressService.list(queryWrappercra); |
|
|
|
|
List<Dz> listdz = new ArrayList<>(); |
|
|
|
|
for (int i = 0 ; i < listcra.size(); i++){ |
|
|
|
|
Dz dz = new Dz(); |
|
|
|
|
dz.setId(listcra.get(i).getId()); |
|
|
|
|
dz.setAddr1(listcra.get(i).getCityId()); |
|
|
|
|
dz.setAddr2(listcra.get(i).getAddress()); |
|
|
|
|
dz.setPostCode(listcra.get(i).getZipCode()); |
|
|
|
|
dz.setFlag(false); |
|
|
|
|
listdz.add(dz); |
|
|
|
|
} |
|
|
|
|
return Result.OK(listdz); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 订单下单数据交互 |
|
|
|
|
* |
|
|
|
|
* @param |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@AutoLog(value = "订单下单数据交互") |
|
|
|
|
@ApiOperation(value="订单下单数据交互", notes="订单下单数据交互") |
|
|
|
|
@GetMapping(value = "/orderXD") |
|
|
|
|
public String orderXD(ZyOrdersJk zyOrdersJk,List<OrderGoodsJk> orderGoodsJkList,HttpServletRequest req,String OrdersNum) { |
|
|
|
|
Double actual_payment = 0.00; |
|
|
|
|
Double money = 0.00; |
|
|
|
|
for(int i = 0 ; i < orderGoodsJkList.size() ; i++){ |
|
|
|
|
ZyGoods zyGoods = zyGoodsService.getById(orderGoodsJkList.get(i).getGoodsId()); |
|
|
|
|
money = money + zyGoods.getUnitPrice()*orderGoodsJkList.get(i).getGoodsNum(); |
|
|
|
|
actual_payment = actual_payment + zyGoods.getPromotionPrice()*orderGoodsJkList.get(i).getGoodsNum(); |
|
|
|
|
} |
|
|
|
|
ZyOrders zyOrders = new ZyOrders(); |
|
|
|
|
zyOrders.setIschild(0); |
|
|
|
|
zyOrders.setOrderTime(new Date()); |
|
|
|
|
zyOrders.setOrdersNum(OrdersNum); |
|
|
|
|
zyOrders.setMoney(money); |
|
|
|
|
zyOrders.setFreight(zyOrdersJk.getFreight()); |
|
|
|
|
zyOrders.setPromotionPrice(money-actual_payment); |
|
|
|
|
zyOrders.setActualPayment(actual_payment); |
|
|
|
|
//交货期先为空
|
|
|
|
|
//zyOrders.setDeliveryTime(zyOrdersJk.getDeliveryTime());
|
|
|
|
|
zyOrders.setOrdersType(zyOrdersJk.getOrdersType()); |
|
|
|
|
zyOrders.setUserId(zyOrdersJk.getUserId()); |
|
|
|
|
CustomerPayment customerPayment = new CustomerPayment(); |
|
|
|
|
QueryWrapper<CustomerPayment> queryWrappercp = QueryGenerator.initQueryWrapper(customerPayment, req.getParameterMap()); |
|
|
|
|
queryWrappercp.eq("user_id",zyOrdersJk.getUserId()); |
|
|
|
|
queryWrappercp.orderByAsc("sort"); |
|
|
|
|
List<CustomerPayment>listcp = iCustomerPaymentService.list(queryWrappercp); |
|
|
|
|
zyOrders.setPaymentMethod(Integer.parseInt(listcp.get(0).getPaymentType())); |
|
|
|
|
zyOrders.setPaymentStatus(0); |
|
|
|
|
zyOrders.setAccountNo(listcp.get(0).getAccountNo()); |
|
|
|
|
zyOrders.setBankDeposit(listcp.get(0).getBankDeposit()); |
|
|
|
|
zyOrders.setGoodsQuantity(zyOrdersJk.getGoodsQuantity()); |
|
|
|
|
CustomerReceivingAddress customerReceivingAddress = iCustomerReceivingAddressService.getById(zyOrdersJk.getAddressId()); |
|
|
|
|
zyOrders.setCityId(customerReceivingAddress.getCityId()); |
|
|
|
|
zyOrders.setAddress(customerReceivingAddress.getAddress()); |
|
|
|
|
zyOrders.setZipCode(customerReceivingAddress.getZipCode()); |
|
|
|
|
zyOrders.setReceiver(zyOrdersJk.getReceiver()); |
|
|
|
|
zyOrders.setMobile(customerReceivingAddress.getMobile()); |
|
|
|
|
CustomerInvoice customerInvoice = iCustomerInvoiceService.getById(zyOrdersJk.getInvoiceId()); |
|
|
|
|
zyOrders.setInvoiceCustomerType(Integer.parseInt(customerInvoice.getCustomerType())); |
|
|
|
|
zyOrders.setInvoiceType(Integer.parseInt(customerInvoice.getInvoiceType())); |
|
|
|
|
zyOrders.setTaxIdentificationNumber(customerInvoice.getTaxIdentificationNumber()); |
|
|
|
|
zyOrders.setAddressBilling(customerInvoice.getAddress()); |
|
|
|
|
zyOrders.setTelephone(customerInvoice.getTelephone()); |
|
|
|
|
zyOrders.setBankPublic(customerInvoice.getBankDeposit()); |
|
|
|
|
zyOrders.setAccountNumber(customerInvoice.getAccountNumber()); |
|
|
|
|
zyOrders.setSalesEnterpriseId(zyOrdersJk.getSalesEnterpriseId()); |
|
|
|
|
zyOrders.setSalespersonId(zyOrdersJk.getSalespersonId()); |
|
|
|
|
//物流企业先空着
|
|
|
|
|
//zyOrders.setLogisticsEnterprisesId(zyOrdersJk.getLogisticsEnterprisesId());
|
|
|
|
|
zyOrders.setDeliveryStatus(0); |
|
|
|
|
zyOrdersService.save(zyOrders); |
|
|
|
|
for(int j = 0 ; j < orderGoodsJkList.size() ; j++){ |
|
|
|
|
ZyGoods zyGoods = zyGoodsService.getById(orderGoodsJkList.get(j).getGoodsId()); |
|
|
|
|
OrderGoods orderGoods = new OrderGoods(); |
|
|
|
|
orderGoods.setOrdersId(zyOrders.getId()); |
|
|
|
|
orderGoods.setGoodsId(orderGoodsJkList.get(j).getGoodsId()); |
|
|
|
|
orderGoods.setGoodsNum(orderGoodsJkList.get(j).getGoodsNum()); |
|
|
|
|
orderGoods.setGoodsCode(zyGoods.getGoodsCode()); |
|
|
|
|
orderGoods.setGoodsName(zyGoods.getGoodsName()); |
|
|
|
|
orderGoods.setGoodsIntr(zyGoods.getGoodsIntr()); |
|
|
|
|
orderGoods.setCustomized(zyGoods.getCustomized()); |
|
|
|
|
orderGoods.setMeasureId(orderGoodsJkList.get(j).getMeasureId()); |
|
|
|
|
orderGoods.setGoodsPicture(zyGoods.getGoodsPicture()); |
|
|
|
|
orderGoods.setDefaultPicture(zyGoods.getDefaultPicture()); |
|
|
|
|
orderGoods.setGoodsVideo(zyGoods.getGoodsVideo()); |
|
|
|
|
orderGoods.setClothsTypeId(zyGoods.getClothsTypeId()); |
|
|
|
|
orderGoods.setStyleId(zyGoods.getStyleId()); |
|
|
|
|
orderGoods.setModelId(zyGoods.getModelId()); |
|
|
|
|
orderGoods.setUnit(zyGoods.getUnit()); |
|
|
|
|
orderGoods.setNumber(zyGoods.getNumber()); |
|
|
|
|
orderGoods.setUnitPrice(zyGoods.getUnitPrice()); |
|
|
|
|
orderGoods.setDiscount(zyGoods.getDiscount()); |
|
|
|
|
orderGoods.setPromotionPrice(zyGoods.getPromotionPrice()); |
|
|
|
|
orderGoods.setRecommend(zyGoods.getRecommend()); |
|
|
|
|
orderGoods.setPlaceOrigin(zyGoods.getPlaceOrigin()); |
|
|
|
|
orderGoods.setStatus(zyGoods.getStatus()); |
|
|
|
|
orderGoods.setTotalPrice(zyGoods.getUnitPrice()*orderGoodsJkList.get(j).getGoodsNum()); |
|
|
|
|
orderGoods.setPayTotalPrice(zyGoods.getPromotionPrice()*orderGoodsJkList.get(j).getGoodsNum()); |
|
|
|
|
orderGoodsService.save(orderGoods); |
|
|
|
|
GoodsModule goodsModule = new GoodsModule(); |
|
|
|
|
QueryWrapper<GoodsModule> queryWrapperzsm = QueryGenerator.initQueryWrapper(goodsModule, req.getParameterMap()); |
|
|
|
|
queryWrapperzsm.eq("goods_id",zyGoods.getId()); |
|
|
|
|
queryWrapperzsm.eq("style_id",zyGoods.getStyleId()); |
|
|
|
|
List<GoodsModule> listzsm = goodsModuleService.list(queryWrapperzsm); |
|
|
|
|
for (int k = 0 ; k < listzsm.size() ; k++){ |
|
|
|
|
OrderGoodsModule orderGoodsModule = new OrderGoodsModule(); |
|
|
|
|
orderGoodsModule.setOrderGoodsId(orderGoods.getId()); |
|
|
|
|
orderGoodsModule.setGoodsId(zyGoods.getId()); |
|
|
|
|
orderGoodsModule.setStyleId(zyGoods.getStyleId()); |
|
|
|
|
orderGoodsModule.setStyleModuleId(listzsm.get(k).getStyleModuleId()); |
|
|
|
|
orderGoodsModule.setModuleId(listzsm.get(k).getModuleId()); |
|
|
|
|
orderGoodsModuleService.save(orderGoodsModule); |
|
|
|
|
} |
|
|
|
|
GoodsFabric goodsFabric = new GoodsFabric(); |
|
|
|
|
QueryWrapper<GoodsFabric> queryWrapperzsf = QueryGenerator.initQueryWrapper(goodsFabric, req.getParameterMap()); |
|
|
|
|
queryWrapperzsf.eq("goods_id",zyGoods.getId()); |
|
|
|
|
List<GoodsFabric> listzsf = goodsFabricService.list(queryWrapperzsf); |
|
|
|
|
for (int o = 0 ; o < listzsf.size() ; o++){ |
|
|
|
|
OrderGoodsFabric orderGoodsFabric = new OrderGoodsFabric(); |
|
|
|
|
orderGoodsFabric.setOrderGoodsId(orderGoods.getId()); |
|
|
|
|
orderGoodsFabric.setGoodsId(zyGoods.getId()); |
|
|
|
|
orderGoodsFabric.setFabricId(listzsf.get(o).getFabricId()); |
|
|
|
|
orderGoodsFabricService.save(orderGoodsFabric); |
|
|
|
|
} |
|
|
|
|
GoodsAccessories goodsAccessories = new GoodsAccessories(); |
|
|
|
|
QueryWrapper<GoodsAccessories> queryWrapperzsa = QueryGenerator.initQueryWrapper(goodsAccessories, req.getParameterMap()); |
|
|
|
|
queryWrapperzsa.eq("goods_id",zyGoods.getId()); |
|
|
|
|
List<GoodsAccessories> listzsa = goodsAccessoriesService.list(queryWrapperzsa); |
|
|
|
|
for (int p = 0 ; p < listzsa.size() ; p++){ |
|
|
|
|
OrderGoodsAccessories orderGoodsAccessories = new OrderGoodsAccessories(); |
|
|
|
|
orderGoodsAccessories.setOrderGoodsId(orderGoods.getId()); |
|
|
|
|
orderGoodsAccessories.setGoodsId(zyGoods.getId()); |
|
|
|
|
orderGoodsAccessories.setAccessoriesId(listzsa.get(p).getAccessoriesId()); |
|
|
|
|
orderGoodsAccessoriesService.save(orderGoodsAccessories); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return zyOrders.getId(); |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* 提交商品订单 |
|
|
|
|
* |
|
|
|
|
* @param |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@AutoLog(value = "提交商品订单") |
|
|
|
|
@ApiOperation(value="提交商品订单", notes="提交商品订单") |
|
|
|
|
@GetMapping(value = "/TJorder") |
|
|
|
|
public Result<?> TJorder(@RequestParam(name="OrdersNum",required=true) String OrdersNum,HttpServletRequest req,@RequestParam(name="goodsid",required=true) String goodsid,@RequestParam(name="goodsNum",required=true) String goodsNum) { |
|
|
|
|
//这里方便获取当前登陆信息
|
|
|
|
|
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
|
|
|
|
//这里获取当前登陆的id
|
|
|
|
|
String userid = loginUser.getId(); |
|
|
|
|
ZyOrdersJk zyOrdersJk = new ZyOrdersJk(); |
|
|
|
|
zyOrdersJk.setFreight(0.0); |
|
|
|
|
zyOrdersJk.setOrdersType(0); |
|
|
|
|
zyOrdersJk.setUserId(userid); |
|
|
|
|
zyOrdersJk.setGoodsQuantity(1); |
|
|
|
|
CustomerReceivingAddress customerReceivingAddress = new CustomerReceivingAddress(); |
|
|
|
|
QueryWrapper<CustomerReceivingAddress> queryWrappercra = QueryGenerator.initQueryWrapper(customerReceivingAddress, req.getParameterMap()); |
|
|
|
|
queryWrappercra.eq("user_id",userid); |
|
|
|
|
queryWrappercra.orderByAsc("sort"); |
|
|
|
|
List<CustomerReceivingAddress> listcra = iCustomerReceivingAddressService.list(queryWrappercra); |
|
|
|
|
zyOrdersJk.setAddressId(listcra.get(0).getId()); |
|
|
|
|
zyOrdersJk.setReceiver(userid); |
|
|
|
|
CustomerInvoice customerInvoice = new CustomerInvoice(); |
|
|
|
|
QueryWrapper<CustomerInvoice> queryWrapperci = QueryGenerator.initQueryWrapper(customerInvoice, req.getParameterMap()); |
|
|
|
|
queryWrapperci.eq("user_id",userid); |
|
|
|
|
queryWrapperci.orderByAsc("sort"); |
|
|
|
|
List<CustomerInvoice> listci = iCustomerInvoiceService.list(queryWrapperci); |
|
|
|
|
zyOrdersJk.setInvoiceId(listci.get(0).getId()); |
|
|
|
|
SysDepart sysDepart = new SysDepart(); |
|
|
|
|
QueryWrapper<SysDepart> queryWrappersd = QueryGenerator.initQueryWrapper(sysDepart, req.getParameterMap()); |
|
|
|
|
queryWrappersd.eq("org_category","4"); |
|
|
|
|
queryWrappersd.orderByAsc("depart_order"); |
|
|
|
|
List<SysDepart> listsd = sysDepartService.list(queryWrappersd); |
|
|
|
|
zyOrdersJk.setSalesEnterpriseId(listsd.get(0).getId()); |
|
|
|
|
SysUser sysUser = new SysUser(); |
|
|
|
|
QueryWrapper<SysUser> queryWrappersu = QueryGenerator.initQueryWrapper(sysUser, req.getParameterMap()); |
|
|
|
|
queryWrappersu.eq("org_code",listsd.get(0).getOrgCode()); |
|
|
|
|
List<SysUser> listsu = sysUserService.list(queryWrappersu); |
|
|
|
|
zyOrdersJk.setSalespersonId(listsu.get(0).getId()); |
|
|
|
|
zyOrdersJk.setDeliveryStatus(0); |
|
|
|
|
List<OrderGoodsJk> orderGoodsJkList = new ArrayList<>(); |
|
|
|
|
OrderGoodsJk orderGoodsJk = new OrderGoodsJk(); |
|
|
|
|
orderGoodsJk.setGoodsId(goodsid); |
|
|
|
|
orderGoodsJk.setGoodsNum(Integer.parseInt(goodsNum)); |
|
|
|
|
CustomerMeasure customerMeasure = new CustomerMeasure(); |
|
|
|
|
QueryWrapper<CustomerMeasure> queryWrappercm = QueryGenerator.initQueryWrapper(customerMeasure, req.getParameterMap()); |
|
|
|
|
queryWrappercm.eq("user_id",userid); |
|
|
|
|
queryWrappercm.orderByAsc("sort"); |
|
|
|
|
List<CustomerMeasure> listcm = iCustomerMeasureService.list(queryWrappercm); |
|
|
|
|
orderGoodsJk.setMeasureId(listcm.get(0).getId()); |
|
|
|
|
orderGoodsJkList.add(orderGoodsJk); |
|
|
|
|
String orderid = orderXD(zyOrdersJk,orderGoodsJkList,req,OrdersNum); |
|
|
|
|
return Result.OK(orderid); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 支付 |
|
|
|
|
* |
|
|
|
|
* @param req |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@AutoLog(value = "支付") |
|
|
|
|
@ApiOperation(value="支付", notes="支付") |
|
|
|
|
@GetMapping(value = "/zf") |
|
|
|
|
public Result<?> zf(@RequestParam(name="ordersid",required=true) String ordersid,@RequestParam(name="goodsid",required=true) String goodsid,HttpServletRequest req) { |
|
|
|
|
ZyOrders zyOrders = zyOrdersService.getById(ordersid); |
|
|
|
|
zyOrders.setPaymentStatus(1); |
|
|
|
|
zyOrders.setPaymentTime(new Date()); |
|
|
|
|
zyOrders.setDeliveryStatus(1); |
|
|
|
|
zyOrdersService.updateById(zyOrders); |
|
|
|
|
ZyGoods zyGoods = zyGoodsService.getById(goodsid); |
|
|
|
|
zyGoods.setNum(zyGoods.getNum()+1); |
|
|
|
|
zyGoodsService.updateById(zyGoods); |
|
|
|
|
return Result.OK("支付成功"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|