parent
c62e4e7c16
commit
558ecd11e9
5 changed files with 1034 additions and 1005 deletions
@ -1,355 +1,354 @@ |
||||
package org.jeecg.modules.demo.zyorders.service.impl; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import org.jeecg.modules.demo.customerinvoice.entity.CustomerInvoice; |
||||
import org.jeecg.modules.demo.customerinvoice.mapper.CustomerInvoiceMapper; |
||||
import org.jeecg.modules.demo.customerreceivingaddress.entity.CustomerReceivingAddress; |
||||
import org.jeecg.modules.demo.customerreceivingaddress.mapper.CustomerReceivingAddressMapper; |
||||
import org.jeecg.modules.demo.goodsaccessories.entity.GoodsAccessories; |
||||
import org.jeecg.modules.demo.goodsaccessories.mapper.GoodsAccessoriesMapper; |
||||
import org.jeecg.modules.demo.goodsfabric.entity.GoodsFabric; |
||||
import org.jeecg.modules.demo.goodsfabric.mapper.GoodsFabricMapper; |
||||
import org.jeecg.modules.demo.goodsmodule.entity.GoodsModule; |
||||
import org.jeecg.modules.demo.goodsmodule.mapper.GoodsModuleMapper; |
||||
import org.jeecg.modules.demo.ordergoods.entity.OrderGoods; |
||||
import org.jeecg.modules.demo.ordergoods.entity.OrderGoodsJk; |
||||
import org.jeecg.modules.demo.ordergoods.mapper.OrderGoodsMapper; |
||||
import org.jeecg.modules.demo.ordergoodsaccessories.entity.OrderGoodsAccessories; |
||||
import org.jeecg.modules.demo.ordergoodsaccessories.mapper.OrderGoodsAccessoriesMapper; |
||||
import org.jeecg.modules.demo.ordergoodsfabric.entity.OrderGoodsFabric; |
||||
import org.jeecg.modules.demo.ordergoodsfabric.mapper.OrderGoodsFabricMapper; |
||||
import org.jeecg.modules.demo.ordergoodsmodule.entity.OrderGoodsModule; |
||||
import org.jeecg.modules.demo.ordergoodsmodule.mapper.OrderGoodsModuleMapper; |
||||
import org.jeecg.modules.demo.zygoods.entity.ZyGoods; |
||||
import org.jeecg.modules.demo.zygoods.mapper.ZyGoodsMapper; |
||||
import org.jeecg.modules.demo.zyorders.entity.ZyOrders; |
||||
import org.jeecg.modules.demo.zyorders.entity.ZyOrdersJk; |
||||
import org.jeecg.modules.demo.zyorders.mapper.ZyOrdersMapper; |
||||
import org.jeecg.modules.demo.zyorders.service.IZyOrdersService; |
||||
import org.jeecg.modules.message.entity.ZySpeechMessage; |
||||
import org.jeecg.modules.message.mapper.ZySpeechMessageMapper; |
||||
import org.jeecg.modules.orderbymakeclothplan.vo.TodayOrderAndQIriVo; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
|
||||
import java.text.SimpleDateFormat; |
||||
import java.util.ArrayList; |
||||
import java.util.Calendar; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @Description: 订单基本信息管理 |
||||
* @Author: jeecg-boot |
||||
* @Date: 2022-12-26 |
||||
* @Version: V1.0 |
||||
*/ |
||||
@Service |
||||
public class ZyOrdersServiceImpl extends ServiceImpl<ZyOrdersMapper, ZyOrders> implements IZyOrdersService { |
||||
|
||||
//商品
|
||||
@Autowired |
||||
private ZyGoodsMapper zyGoodsMapper; |
||||
|
||||
//订单商品表
|
||||
@Autowired |
||||
private OrderGoodsMapper zyOrderGoodsMapper; |
||||
|
||||
//商品模块表
|
||||
@Autowired |
||||
private GoodsModuleMapper zyGoodsModuleMapper; |
||||
|
||||
|
||||
//订单商品模块表
|
||||
@Autowired |
||||
private OrderGoodsModuleMapper zyOrderGoodsModuleMapper; |
||||
|
||||
|
||||
//商品面料表
|
||||
@Autowired |
||||
private GoodsFabricMapper zyGoodsFabricMapper; |
||||
|
||||
//订单商品面料表
|
||||
@Autowired |
||||
private OrderGoodsFabricMapper zyOrderGoodsFabricMapper; |
||||
|
||||
//商品辅料表
|
||||
@Autowired |
||||
private GoodsAccessoriesMapper zyGoodsAccessoriesMapper; |
||||
|
||||
//订单商品辅料表
|
||||
@Autowired |
||||
private OrderGoodsAccessoriesMapper zyOrderGoodsAccessoriesMapper; |
||||
|
||||
|
||||
|
||||
//顾客地址表
|
||||
@Autowired |
||||
CustomerReceivingAddressMapper customerReceivingAddressMapper; |
||||
|
||||
//客户发票信息
|
||||
@Autowired |
||||
CustomerInvoiceMapper customerInvoiceMapper; |
||||
|
||||
//定时播报
|
||||
@Autowired |
||||
private ZySpeechMessageMapper zySpeechMessageMapper; |
||||
|
||||
|
||||
|
||||
|
||||
/** |
||||
* 大屏数据-获取订单的状态 |
||||
* @return |
||||
*/ |
||||
@Override |
||||
public List<ZyOrders> getOrderStatus() { |
||||
String starTime; |
||||
String endTime; |
||||
Date date = new Date(); |
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); |
||||
String todayStr = formatter.format(date);//今天
|
||||
Calendar calendar = Calendar.getInstance(); |
||||
calendar.setTime(date); |
||||
//把日期往后增加一天.整数往后推,负数往前移动(1:表示明天、-1:表示昨天,0:表示今天)
|
||||
calendar.add(Calendar.DATE, 1); |
||||
//这个时间就是日期往后推一天的结果,明天
|
||||
date = calendar.getTime(); |
||||
String tomorrowStr = formatter.format(date); |
||||
|
||||
starTime = todayStr + " 00:00:00"; |
||||
endTime = tomorrowStr + " 00:00:00"; |
||||
|
||||
QueryWrapper<ZyOrders> wrapper = new QueryWrapper<>(); |
||||
wrapper.ge("create_time", starTime).le("create_time", endTime).eq("payment_status", 1); |
||||
|
||||
List<ZyOrders> zyOrderList = baseMapper.selectList(wrapper); |
||||
return zyOrderList; |
||||
} |
||||
|
||||
/** |
||||
* 大屏数据-获取历史订单 |
||||
* @return |
||||
*/ |
||||
@Override |
||||
public List<ZyOrders> getOldOrder() { |
||||
QueryWrapper<ZyOrders> wrapper = new QueryWrapper<>(); |
||||
wrapper |
||||
// .eq("is_delete", 0)
|
||||
.orderByDesc("create_time"); |
||||
List<ZyOrders> orderList = baseMapper.selectList(wrapper); |
||||
return orderList; |
||||
} |
||||
|
||||
/** |
||||
* 获取今日订单及七日订单 |
||||
* @return |
||||
*/ |
||||
@Override |
||||
public TodayOrderAndQIriVo getOrder() { |
||||
TodayOrderAndQIriVo todayOrderAndQIriVo = baseMapper.getTotalOrderAndWeek(); |
||||
if (todayOrderAndQIriVo != null) { |
||||
return todayOrderAndQIriVo; |
||||
} else { |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* |
||||
* @param zyOrdersJk |
||||
* @param orderGoodsJkList |
||||
* @return |
||||
*/ |
||||
@Override |
||||
public List<String> orderJk(ZyOrdersJk zyOrdersJk, List<OrderGoodsJk> orderGoodsJkList) { |
||||
|
||||
Double actual_payment = 0.00; |
||||
Double money = 0.00; |
||||
for(int i = 0 ; i < orderGoodsJkList.size() ; i++){ |
||||
ZyGoods zyGoods = zyGoodsMapper.selectById(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(getOrdersNum()); |
||||
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()); |
||||
zyOrders.setGoodsQuantity(zyOrdersJk.getGoodsQuantity()); |
||||
//顾客地址
|
||||
if(zyOrdersJk.getAddressId()!=null&&zyOrdersJk.getAddressId()!="") |
||||
{ |
||||
CustomerReceivingAddress customerReceivingAddress = customerReceivingAddressMapper.selectById(zyOrdersJk.getAddressId()); |
||||
zyOrders.setCityId(customerReceivingAddress.getCityId()); |
||||
zyOrders.setAddress(customerReceivingAddress.getAddress()); |
||||
zyOrders.setZipCode(customerReceivingAddress.getZipCode()); |
||||
zyOrders.setReceiver(zyOrdersJk.getReceiver()); |
||||
zyOrders.setMobile(customerReceivingAddress.getMobile()); |
||||
} |
||||
|
||||
//顾客发票
|
||||
if(zyOrdersJk.getInvoiceId()!=null&&zyOrdersJk.getInvoiceId()!="") |
||||
{ |
||||
CustomerInvoice customerInvoice = customerInvoiceMapper.selectById(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); |
||||
zyOrders.setPaymentStatus(1); |
||||
zyOrders.setPaymentTime(new Date()); |
||||
baseMapper.insert(zyOrders); |
||||
for(int j = 0 ; j < orderGoodsJkList.size() ; j++){ |
||||
ZyGoods zyGoods = zyGoodsMapper.selectById(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(zyOrdersJk.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()); |
||||
zyOrderGoodsMapper.insert(orderGoods); |
||||
GoodsModule goodsModule = new GoodsModule(); |
||||
QueryWrapper<GoodsModule> queryWrapperzsm = new QueryWrapper(); |
||||
queryWrapperzsm.eq("goods_id",zyGoods.getId()); |
||||
queryWrapperzsm.eq("style_id",zyGoods.getStyleId()); |
||||
List<GoodsModule> listzsm = zyGoodsModuleMapper.selectList(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()); |
||||
zyOrderGoodsModuleMapper.insert(orderGoodsModule); |
||||
} |
||||
GoodsFabric goodsFabric = new GoodsFabric(); |
||||
QueryWrapper<GoodsFabric> queryWrapperzsf =new QueryWrapper(); |
||||
queryWrapperzsf.eq("goods_id",zyGoods.getId()); |
||||
List<GoodsFabric> listzsf = zyGoodsFabricMapper.selectList(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()); |
||||
zyOrderGoodsFabricMapper.insert(orderGoodsFabric); |
||||
} |
||||
GoodsAccessories goodsAccessories = new GoodsAccessories(); |
||||
QueryWrapper<GoodsAccessories> queryWrapperzsa = new QueryWrapper(); |
||||
queryWrapperzsa.eq("goods_id",zyGoods.getId()); |
||||
List<GoodsAccessories> listzsa = zyGoodsAccessoriesMapper.selectList(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()); |
||||
zyOrderGoodsAccessoriesMapper.insert(orderGoodsAccessories); |
||||
} |
||||
|
||||
|
||||
} |
||||
List<String> ids = new ArrayList<>(); |
||||
ZyOrders zos = new ZyOrders(); |
||||
QueryWrapper<ZyOrders> queryWrapperzos = new QueryWrapper(); |
||||
queryWrapperzos.eq("order_id",zyOrders.getId()); |
||||
List<ZyOrders> listzos = baseMapper.selectList(queryWrapperzos); |
||||
if(listzos.size()>0){ |
||||
//return Result.error("该订单已经拆分,不可以再次拆单!");
|
||||
return null; |
||||
}else{ |
||||
OrderGoods orderGoods = new OrderGoods(); |
||||
QueryWrapper<OrderGoods> queryWrapperog = new QueryWrapper(); |
||||
queryWrapperog.eq("orders_id",zyOrders.getId()); |
||||
List<OrderGoods> listog = zyOrderGoodsMapper.selectList(queryWrapperog); |
||||
if(listog.size()>0){ |
||||
for (int i = 0 ; i < listog.size() ; i++){ |
||||
ZyOrders zo = new ZyOrders(); |
||||
zo = zyOrders; |
||||
zo.setId(null); |
||||
zo.setOrdersNum(getOrdersNum()); |
||||
zo.setOrderId(listog.get(i).getId()); |
||||
zo.setFreight(Double.parseDouble("0")); |
||||
zo.setIschild(1); |
||||
zo.setOrderId(zyOrders.getId()); |
||||
zo.setMoney(listog.get(i).getTotalPrice()); |
||||
zo.setPromotionPrice(listog.get(i).getPromotionPrice()); |
||||
zo.setActualPayment(listog.get(i).getPayTotalPrice()); |
||||
zo.setGoodsQuantity(1); |
||||
baseMapper.insert(zo); |
||||
ids.add(zo.getId()); |
||||
OrderGoods og = new OrderGoods(); |
||||
og = listog.get(i); |
||||
og.setOrdersId(zo.getId()); |
||||
zyOrderGoodsMapper.updateById(og); |
||||
//定时播报
|
||||
ZySpeechMessage message=new ZySpeechMessage(); |
||||
//订单商品id
|
||||
message.setOrdergoodsId(zo.getId()); |
||||
// //工单id
|
||||
// message.setWorkorderId();
|
||||
// //生产计划工序id
|
||||
// message.setZyplanprocessId();
|
||||
//消息
|
||||
message.setMessage("您有新的订单,订单编号:"+zo.getOrdersNum()+",请及时查看!"); |
||||
zySpeechMessageMapper.insert(message); |
||||
} |
||||
} |
||||
} |
||||
return ids; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 生成订单编号 |
||||
* |
||||
* @param |
||||
* @return |
||||
*/ |
||||
public String getOrdersNum() { |
||||
String mrstr = "000000000000000000"; |
||||
QueryWrapper<ZyOrders> qw=new QueryWrapper(); |
||||
int listsize = baseMapper.selectCount(qw); |
||||
int strsize = listsize+1; |
||||
String str = strsize+""; |
||||
int strlength = str.length(); |
||||
String substr = mrstr.substring(0,mrstr.length()-strlength); |
||||
String OrdersNum = substr+str; |
||||
return OrdersNum; |
||||
} |
||||
|
||||
} |
||||
package org.jeecg.modules.demo.zyorders.service.impl; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import org.jeecg.modules.demo.customerinvoice.entity.CustomerInvoice; |
||||
import org.jeecg.modules.demo.customerinvoice.mapper.CustomerInvoiceMapper; |
||||
import org.jeecg.modules.demo.customerreceivingaddress.entity.CustomerReceivingAddress; |
||||
import org.jeecg.modules.demo.customerreceivingaddress.mapper.CustomerReceivingAddressMapper; |
||||
import org.jeecg.modules.demo.goodsaccessories.entity.GoodsAccessories; |
||||
import org.jeecg.modules.demo.goodsaccessories.mapper.GoodsAccessoriesMapper; |
||||
import org.jeecg.modules.demo.goodsfabric.entity.GoodsFabric; |
||||
import org.jeecg.modules.demo.goodsfabric.mapper.GoodsFabricMapper; |
||||
import org.jeecg.modules.demo.goodsmodule.entity.GoodsModule; |
||||
import org.jeecg.modules.demo.goodsmodule.mapper.GoodsModuleMapper; |
||||
import org.jeecg.modules.demo.ordergoods.entity.OrderGoods; |
||||
import org.jeecg.modules.demo.ordergoods.entity.OrderGoodsJk; |
||||
import org.jeecg.modules.demo.ordergoods.mapper.OrderGoodsMapper; |
||||
import org.jeecg.modules.demo.ordergoodsaccessories.entity.OrderGoodsAccessories; |
||||
import org.jeecg.modules.demo.ordergoodsaccessories.mapper.OrderGoodsAccessoriesMapper; |
||||
import org.jeecg.modules.demo.ordergoodsfabric.entity.OrderGoodsFabric; |
||||
import org.jeecg.modules.demo.ordergoodsfabric.mapper.OrderGoodsFabricMapper; |
||||
import org.jeecg.modules.demo.ordergoodsmodule.entity.OrderGoodsModule; |
||||
import org.jeecg.modules.demo.ordergoodsmodule.mapper.OrderGoodsModuleMapper; |
||||
import org.jeecg.modules.demo.zygoods.entity.ZyGoods; |
||||
import org.jeecg.modules.demo.zygoods.mapper.ZyGoodsMapper; |
||||
import org.jeecg.modules.demo.zyorders.entity.ZyOrders; |
||||
import org.jeecg.modules.demo.zyorders.entity.ZyOrdersJk; |
||||
import org.jeecg.modules.demo.zyorders.mapper.ZyOrdersMapper; |
||||
import org.jeecg.modules.demo.zyorders.service.IZyOrdersService; |
||||
import org.jeecg.modules.message.entity.ZySpeechMessage; |
||||
import org.jeecg.modules.message.mapper.ZySpeechMessageMapper; |
||||
import org.jeecg.modules.orderbymakeclothplan.vo.TodayOrderAndQIriVo; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
|
||||
import java.text.SimpleDateFormat; |
||||
import java.util.ArrayList; |
||||
import java.util.Calendar; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @Description: 订单基本信息管理 |
||||
* @Author: jeecg-boot |
||||
* @Date: 2022-12-26 |
||||
* @Version: V1.0 |
||||
*/ |
||||
@Service |
||||
public class ZyOrdersServiceImpl extends ServiceImpl<ZyOrdersMapper, ZyOrders> implements IZyOrdersService { |
||||
|
||||
//商品
|
||||
@Autowired |
||||
private ZyGoodsMapper zyGoodsMapper; |
||||
|
||||
//订单商品表
|
||||
@Autowired |
||||
private OrderGoodsMapper zyOrderGoodsMapper; |
||||
|
||||
//商品模块表
|
||||
@Autowired |
||||
private GoodsModuleMapper zyGoodsModuleMapper; |
||||
|
||||
|
||||
//订单商品模块表
|
||||
@Autowired |
||||
private OrderGoodsModuleMapper zyOrderGoodsModuleMapper; |
||||
|
||||
|
||||
//商品面料表
|
||||
@Autowired |
||||
private GoodsFabricMapper zyGoodsFabricMapper; |
||||
|
||||
//订单商品面料表
|
||||
@Autowired |
||||
private OrderGoodsFabricMapper zyOrderGoodsFabricMapper; |
||||
|
||||
//商品辅料表
|
||||
@Autowired |
||||
private GoodsAccessoriesMapper zyGoodsAccessoriesMapper; |
||||
|
||||
//订单商品辅料表
|
||||
@Autowired |
||||
private OrderGoodsAccessoriesMapper zyOrderGoodsAccessoriesMapper; |
||||
|
||||
|
||||
//顾客地址表
|
||||
@Autowired |
||||
CustomerReceivingAddressMapper customerReceivingAddressMapper; |
||||
|
||||
//客户发票信息
|
||||
@Autowired |
||||
CustomerInvoiceMapper customerInvoiceMapper; |
||||
|
||||
//定时播报
|
||||
@Autowired |
||||
private ZySpeechMessageMapper zySpeechMessageMapper; |
||||
|
||||
|
||||
/** |
||||
* 大屏数据-获取订单的状态 |
||||
* |
||||
* @return |
||||
*/ |
||||
@Override |
||||
public List<ZyOrders> getOrderStatus() { |
||||
String starTime; |
||||
String endTime; |
||||
Date date = new Date(); |
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); |
||||
String todayStr = formatter.format(date);//今天
|
||||
Calendar calendar = Calendar.getInstance(); |
||||
calendar.setTime(date); |
||||
//把日期往后增加一天.整数往后推,负数往前移动(1:表示明天、-1:表示昨天,0:表示今天)
|
||||
calendar.add(Calendar.DATE, 1); |
||||
//这个时间就是日期往后推一天的结果,明天
|
||||
date = calendar.getTime(); |
||||
String tomorrowStr = formatter.format(date); |
||||
|
||||
starTime = todayStr + " 00:00:00"; |
||||
endTime = tomorrowStr + " 00:00:00"; |
||||
|
||||
QueryWrapper<ZyOrders> wrapper = new QueryWrapper<>(); |
||||
wrapper.ge("create_time", starTime).le("create_time", endTime).eq("payment_status", 1); |
||||
|
||||
List<ZyOrders> zyOrderList = baseMapper.selectList(wrapper); |
||||
return zyOrderList; |
||||
} |
||||
|
||||
/** |
||||
* 大屏数据-获取历史订单 |
||||
* |
||||
* @return |
||||
*/ |
||||
@Override |
||||
public List<ZyOrders> getOldOrder() { |
||||
QueryWrapper<ZyOrders> wrapper = new QueryWrapper<>(); |
||||
wrapper |
||||
// .eq("is_delete", 0)
|
||||
.orderByDesc("create_time"); |
||||
List<ZyOrders> orderList = baseMapper.selectList(wrapper); |
||||
return orderList; |
||||
} |
||||
|
||||
/** |
||||
* 获取今日订单及七日订单 |
||||
* |
||||
* @return |
||||
*/ |
||||
@Override |
||||
public TodayOrderAndQIriVo getOrder() { |
||||
TodayOrderAndQIriVo todayOrderAndQIriVo = baseMapper.getTotalOrderAndWeek(); |
||||
if (todayOrderAndQIriVo != null) { |
||||
return todayOrderAndQIriVo; |
||||
} else { |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* @param zyOrdersJk |
||||
* @param orderGoodsJkList |
||||
* @return |
||||
*/ |
||||
@Override |
||||
public List<String> orderJk(ZyOrdersJk zyOrdersJk, List<OrderGoodsJk> orderGoodsJkList) { |
||||
|
||||
Double actual_payment = 0.00; |
||||
Double money = 0.00; |
||||
for (int i = 0; i < orderGoodsJkList.size(); i++) { |
||||
ZyGoods zyGoods = zyGoodsMapper.selectById(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(getOrdersNum()); |
||||
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()); |
||||
zyOrders.setGoodsQuantity(zyOrdersJk.getGoodsQuantity()); |
||||
//顾客地址
|
||||
if (zyOrdersJk.getAddressId() != null && zyOrdersJk.getAddressId() != "") { |
||||
CustomerReceivingAddress customerReceivingAddress = customerReceivingAddressMapper.selectById(zyOrdersJk.getAddressId()); |
||||
zyOrders.setCityId(customerReceivingAddress.getCityId()); |
||||
zyOrders.setAddress(customerReceivingAddress.getAddress()); |
||||
zyOrders.setZipCode(customerReceivingAddress.getZipCode()); |
||||
zyOrders.setReceiver(zyOrdersJk.getReceiver()); |
||||
zyOrders.setMobile(customerReceivingAddress.getMobile()); |
||||
} |
||||
|
||||
//顾客发票
|
||||
if (zyOrdersJk.getInvoiceId() != null && zyOrdersJk.getInvoiceId() != "") { |
||||
CustomerInvoice customerInvoice = customerInvoiceMapper.selectById(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); |
||||
zyOrders.setPaymentStatus(1); |
||||
zyOrders.setPaymentTime(new Date()); |
||||
baseMapper.insert(zyOrders); |
||||
for (int j = 0; j < orderGoodsJkList.size(); j++) { |
||||
ZyGoods zyGoods = zyGoodsMapper.selectById(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(zyOrdersJk.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()); |
||||
zyOrderGoodsMapper.insert(orderGoods); |
||||
GoodsModule goodsModule = new GoodsModule(); |
||||
QueryWrapper<GoodsModule> queryWrapperzsm = new QueryWrapper(); |
||||
queryWrapperzsm.eq("goods_id", zyGoods.getId()); |
||||
queryWrapperzsm.eq("style_id", zyGoods.getStyleId()); |
||||
List<GoodsModule> listzsm = zyGoodsModuleMapper.selectList(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()); |
||||
zyOrderGoodsModuleMapper.insert(orderGoodsModule); |
||||
} |
||||
GoodsFabric goodsFabric = new GoodsFabric(); |
||||
QueryWrapper<GoodsFabric> queryWrapperzsf = new QueryWrapper(); |
||||
queryWrapperzsf.eq("goods_id", zyGoods.getId()); |
||||
List<GoodsFabric> listzsf = zyGoodsFabricMapper.selectList(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()); |
||||
zyOrderGoodsFabricMapper.insert(orderGoodsFabric); |
||||
} |
||||
GoodsAccessories goodsAccessories = new GoodsAccessories(); |
||||
QueryWrapper<GoodsAccessories> queryWrapperzsa = new QueryWrapper(); |
||||
queryWrapperzsa.eq("goods_id", zyGoods.getId()); |
||||
List<GoodsAccessories> listzsa = zyGoodsAccessoriesMapper.selectList(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()); |
||||
zyOrderGoodsAccessoriesMapper.insert(orderGoodsAccessories); |
||||
} |
||||
|
||||
|
||||
} |
||||
List<String> ids = new ArrayList<>(); |
||||
ZyOrders zos = new ZyOrders(); |
||||
QueryWrapper<ZyOrders> queryWrapperzos = new QueryWrapper(); |
||||
queryWrapperzos.eq("order_id", zyOrders.getId()); |
||||
List<ZyOrders> listzos = baseMapper.selectList(queryWrapperzos); |
||||
if (listzos.size() > 0) { |
||||
//return Result.error("该订单已经拆分,不可以再次拆单!");
|
||||
return null; |
||||
} else { |
||||
OrderGoods orderGoods = new OrderGoods(); |
||||
QueryWrapper<OrderGoods> queryWrapperog = new QueryWrapper(); |
||||
queryWrapperog.eq("orders_id", zyOrders.getId()); |
||||
List<OrderGoods> listog = zyOrderGoodsMapper.selectList(queryWrapperog); |
||||
if (listog.size() > 0) { |
||||
for (int i = 0; i < listog.size(); i++) { |
||||
ZyOrders zo = new ZyOrders(); |
||||
zo = zyOrders; |
||||
zo.setId(null); |
||||
zo.setOrdersNum(getOrdersNum()); |
||||
zo.setOrderId(listog.get(i).getId()); |
||||
zo.setFreight(Double.parseDouble("0")); |
||||
zo.setIschild(1); |
||||
zo.setOrderId(zyOrders.getId()); |
||||
zo.setMoney(listog.get(i).getTotalPrice()); |
||||
zo.setPromotionPrice(listog.get(i).getPromotionPrice()); |
||||
zo.setActualPayment(listog.get(i).getPayTotalPrice()); |
||||
zo.setGoodsQuantity(1); |
||||
baseMapper.insert(zo); |
||||
ids.add(zo.getId()); |
||||
OrderGoods og = new OrderGoods(); |
||||
og = listog.get(i); |
||||
og.setOrdersId(zo.getId()); |
||||
zyOrderGoodsMapper.updateById(og); |
||||
//定时播报
|
||||
ZySpeechMessage message = new ZySpeechMessage(); |
||||
//订单商品id
|
||||
message.setOrdergoodsId(zo.getId()); |
||||
// //工单id
|
||||
// message.setWorkorderId();
|
||||
// //生产计划工序id
|
||||
// message.setZyplanprocessId();
|
||||
//消息
|
||||
String ordersNum = zo.getOrdersNum(); |
||||
String code = ordersNum.substring(ordersNum.length() - 6); |
||||
message.setMessage("您有新的订单,订单尾号:" + code + ",请及时查看!"); |
||||
zySpeechMessageMapper.insert(message); |
||||
} |
||||
} |
||||
} |
||||
return ids; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 生成订单编号 |
||||
* |
||||
* @param |
||||
* @return |
||||
*/ |
||||
public String getOrdersNum() { |
||||
String mrstr = "000000000000000000"; |
||||
QueryWrapper<ZyOrders> qw = new QueryWrapper(); |
||||
int listsize = baseMapper.selectCount(qw); |
||||
int strsize = listsize + 1; |
||||
String str = strsize + ""; |
||||
int strlength = str.length(); |
||||
String substr = mrstr.substring(0, mrstr.length() - strlength); |
||||
String OrdersNum = substr + str; |
||||
return OrdersNum; |
||||
} |
||||
|
||||
} |
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue