springcloud_k8s_panzhihuazhihuishequ/applets_backstage/src/main/java/com/panzhihua/applets_backstage/api/ShopApi.java
@@ -226,15 +226,6 @@ //String name=uuid+".xlsx"; String ftpUrl = "/mnt/data/web/excel/"; R<ShopStoreVO> storeR = communityService.getUserStoreInfo(getUserId()); if (!R.isOk(storeR)) { return R.fail("用户不是商家"); } ShopStoreVO shopStoreVO = JSONObject.parseObject(JSONObject.toJSONString(storeR.getData()), ShopStoreVO.class); Long userId = this.getUserId(); comShopOrderExportDTO.setUserId(userId); R r = communityService.shopOrderExportData(comShopOrderExportDTO); if (R.isOk(r)) { List<ExcelShopOrderDTO> excelShopOrderDTO = JSONArray.parseArray(JSONArray.toJSONString(r.getData()), ExcelShopOrderDTO.class); @@ -244,7 +235,7 @@ try { SFTPUtil sftp = new SFTPUtil(userName, password, host, port); sftp.login(); String name = shopStoreVO.getName() + "商城订单-" + new SimpleDateFormat("yyyyMMddhhmmss").format(new Date()) + ".xlsx"; String name = "商城订单-" + new SimpleDateFormat("yyyyMMddhhmmss").format(new Date()) + ".xlsx"; boolean existDir = sftp.isExistDir(ftpUrl + name); if (!existDir) { String property = System.getProperty("user.dir"); @@ -254,7 +245,7 @@ InputStream inputStream = null; try { excelWriter = EasyExcel.write(fileName, ExcelShopOrderDTO.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).registerWriteHandler(new CustomSheetWriteHandler()).build(); WriteSheet writeSheet = EasyExcel.writerSheet(shopStoreVO.getName() + "订单").build(); WriteSheet writeSheet = EasyExcel.writerSheet("订单").build(); excelWriter.write(excelShopOrderDTO, writeSheet); excelWriter.finish(); File file = new File(fileName); @@ -318,13 +309,6 @@ //String name=uuid+".xlsx"; String ftpUrl = "/mnt/data/web/excel/"; R<ShopStoreVO> storeR = communityService.getUserStoreInfo(getUserId()); if (!R.isOk(storeR)) { return R.fail("用户不是商家"); } ShopStoreVO shopStoreVO = JSONObject.parseObject(JSONObject.toJSONString(storeR.getData()), ShopStoreVO.class); Long userId = this.getUserId(); comShopFundsExportDTO.setUserId(userId); R r = communityService.shopOrderFundsExportData(comShopFundsExportDTO); @@ -336,7 +320,7 @@ try { SFTPUtil sftp = new SFTPUtil(userName, password, host, port); sftp.login(); String name = shopStoreVO.getName() + "-商家资金流水-" + new SimpleDateFormat("yyyyMMddhhmmss").format(new Date()) + ".xlsx"; String name = "商家资金流水-" + new SimpleDateFormat("yyyyMMddhhmmss").format(new Date()) + ".xlsx"; boolean existDir = sftp.isExistDir(ftpUrl + name); if (!existDir) { String property = System.getProperty("user.dir"); @@ -346,7 +330,7 @@ InputStream inputStream = null; try { excelWriter = EasyExcel.write(fileName, ExcelShopFundsDTO.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).registerWriteHandler(new CustomSheetWriteHandler()).build(); WriteSheet writeSheet = EasyExcel.writerSheet(shopStoreVO.getName() + "订单").build(); WriteSheet writeSheet = EasyExcel.writerSheet("订单").build(); excelWriter.write(excelShopFundsDTO, writeSheet); excelWriter.finish(); File file = new File(fileName); @@ -376,4 +360,11 @@ } return R.fail("导出数据失败"); } @ApiOperation(value = "配送完成") @PutMapping("/order/finishDeliver") public R finishDeliver(@RequestBody ComShopOrderDeliverDTO deliverDTO){ return communityService.finishDeliverOrder(deliverDTO); } } springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/shop/ComShopOrderDeliverDTO.java
@@ -15,10 +15,8 @@ * @Version 1.0 **/ @Data @ApiModel("订单发货信息") @ApiModel("订单配送信息") public class ComShopOrderDeliverDTO { @ApiModelProperty(value = "订单号") private String orderNo; @ApiModelProperty(value = "订单ID") private Long orderId; } springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/shop/ComShopOrderShipDTO.java
@@ -14,8 +14,6 @@ @Data @ApiModel("订单发货信息") public class ComShopOrderShipDTO { @ApiModelProperty(value = "订单号") private String orderNo; @ApiModelProperty(value = "ID") private Long orderId; @ApiModelProperty(value = "物流公司") springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/shop/AddShopGoodsAttrVO.java
@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.Min; import java.math.BigDecimal; /** @@ -21,5 +22,6 @@ private String goodsAttr; @ApiModelProperty("规格价格") @Min(value = 0,message = "价格最小值为0") private BigDecimal attrPrice; } springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/shop/AddShopGoodsVO.java
@@ -4,6 +4,8 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.Max; import javax.validation.constraints.Min; import java.math.BigDecimal; import java.util.List; @@ -23,6 +25,7 @@ private String name; @ApiModelProperty("商品现价") @Min(value = 0,message = "价格最小值为0") private BigDecimal price; springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/shop/ComShopOrderSearchVO.java
@@ -26,6 +26,9 @@ @ApiModelProperty("店铺id") private Long storeId; @ApiModelProperty("店铺名称") private String storeName; @ApiModelProperty("用户id") private Long userId; springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/utlis/DifferentLongListUtil.java
New file @@ -0,0 +1,50 @@ package com.panzhihua.common.utlis; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /** * @Author: llming * @Description: 获取不同两个list不同元素 */ public class DifferentLongListUtil { public static List<Long> getDiffrent(List<Long> list1, List<Long> list2) { Map<Long, Integer> map = new HashMap<Long, Integer>(list1.size() + list2.size()); List<Long> diff = new ArrayList<Long>(); List<Long> maxList = list1; List<Long> minList = list2; if (list2.size() > list1.size()) { maxList = list2; minList = list1; } for (Long Long : maxList) { map.put(Long, 1); } for (Long Long : minList) { Integer cc = map.get(Long); if (cc != null) { map.put(Long, ++cc); continue; } map.put(Long, 1); } for (Map.Entry<Long, Integer> entry : map.entrySet()) { if (entry.getValue() == 1) { diff.add(entry.getKey()); } } return diff; } public static void main(Long[] args) { // List<Long> Longs1 = Arrays.asList(1L, 2L, 2L, 3L, 4L); // List<Long> Longs2 = Arrays.asList(1L, 2L, 5L, 6L, 4L); // List<Long> diffrent = getDiffrent(Longs1, Longs2); // System.out.println(diffrent); } } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComShopOrderDAO.java
@@ -38,7 +38,7 @@ " sr.wx_tarde_no, sr.status, sr.pay_status, sr.receiver_id, \n" + " sr.total_amount, sr.discount_amount, sr.pay_amount, sr.pay_type, \n" + " sr.pay_time, sr.delivery_type, sr.delivery_status, sr.logistics_company, \n" + " sr.logistics_no, sr.create_at, uad.name as receiver_name, uad.phone as receiver_phone, group_concat(og.goods_name) as goodsName \n" + " sr.logistics_no, sr.create_at, uad.name as receiver_name, uad.phone as receiver_phone, group_concat(og.goods_name) as goodsName, ss.name as store_name \n" + " FROM com_shop_order sr LEFT JOIN com_shop_order_goods og ON sr.id = og.order_id \n" + " LEFT JOIN com_shop_goods_attr ga ON og.goods_attr_id = ga.id \n" + " LEFT JOIN sys_user su ON sr.user_id = su.user_id \n" + @@ -82,7 +82,7 @@ " AND ss.sys_user_id = #{pageComShopOrderSearchDTO.storeUserId} " + " </if> " + " GROUP BY sr.id " + " ORDER BY sr.create_at "+ " ORDER BY sr.create_at DESC "+ "</script>") IPage<ComShopOrderSearchVO> pageOrderBy(Page page, @Param("pageComShopOrderSearchDTO") PageComShopOrderSearchDTO pageComShopOrderSearchDTO); @@ -232,7 +232,7 @@ "<if test='pageComShopFundsSearchDTO.orderNo != null '>" + " AND sr.order_no = #{pageComShopFundsSearchDTO.orderNo} " + " </if> " + " GROUP BY sr.id ORDER BY sr.create_at "+ " GROUP BY sr.id ORDER BY sr.create_at DESC "+ "</script>") IPage<ComShopFundsOrderVO> pageShopFunds(Page page, @Param("pageComShopFundsSearchDTO") PageComShopFundsSearchDTO pageComShopFundsSearchDTO); springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComShopGoodsServiceImpl.java
@@ -13,6 +13,7 @@ import com.panzhihua.common.model.vos.shop.AddShopGoodsAttrVO; import com.panzhihua.common.model.vos.shop.PageShopGoodsVO; import com.panzhihua.common.model.vos.shop.AddShopGoodsVO; import com.panzhihua.common.utlis.DifferentLongListUtil; import com.panzhihua.common.utlis.StringUtils; import com.panzhihua.service_community.dao.ComShopGoodsAttrDAO; import com.panzhihua.common.model.vos.shop.ComShopGoodsAttrVO; @@ -31,6 +32,7 @@ import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; /** * @auther lyq @@ -55,6 +57,7 @@ String[] images = addShopGoodsVO.getGoodsPic().split(","); ComShopGoodsDO shopGoodsDO = new ComShopGoodsDO(); BeanUtils.copyProperties(addShopGoodsVO, shopGoodsDO); shopGoodsDO.setOriginalPrice(addShopGoodsVO.getPrice()); if (images.length > 1) { shopGoodsDO.setGoodsPic(images[0]); } @@ -126,36 +129,50 @@ LambdaQueryWrapper<ComShopGoodsDO> query = new LambdaQueryWrapper<ComShopGoodsDO>().eq(ComShopGoodsDO::getId, id); ComShopGoodsDO shopGoodsDO = new ComShopGoodsDO(); BeanUtils.copyProperties(addShopGoodsVO, shopGoodsDO); shopGoodsDO.setOriginalPrice(addShopGoodsVO.getPrice()); int update = this.baseMapper.update(shopGoodsDO, query); if (update < 1) { throw new ServiceException("修改失败"); } ArrayList<ComShopGoodsAttrDO> goodsAttrDOS = Lists.newArrayList(); addShopGoodsVO.getGoodsAttrVOList().forEach(goodsAttr -> { if (goodsAttr.getGoodsAttrId() == null) { throw new ServiceException("规格Id为空"); //修改规格表 List<ComShopGoodsAttrDO> comShopGoodsAttrDOS = shopGoodsAttrDAO.selectList(new LambdaQueryWrapper<ComShopGoodsAttrDO>().eq(ComShopGoodsAttrDO::getGoodsId, id)); if (addShopGoodsVO.getGoodsAttrVOList().size() == 0) { shopGoodsAttrDAO.delete(new LambdaQueryWrapper<ComShopGoodsAttrDO>().eq(ComShopGoodsAttrDO::getGoodsId, id)); ComShopGoodsAttrDO comShopGoodsAttrDO = new ComShopGoodsAttrDO(); comShopGoodsAttrDO.setGoodsId(id); comShopGoodsAttrDO.setStoreId(addShopGoodsVO.getStoreId()); comShopGoodsAttrDO.setGoodsName(addShopGoodsVO.getName()); comShopGoodsAttrDO.setGoodsAttr("默认"); comShopGoodsAttrDO.setAttrPic(addShopGoodsVO.getGoodsPic()); comShopGoodsAttrDO.setIsDefault(1); comShopGoodsAttrDO.setPrice(addShopGoodsVO.getPrice()); shopGoodsAttrDAO.insert(comShopGoodsAttrDO); }else{ List<Long> attrIds = comShopGoodsAttrDOS.stream().map(ComShopGoodsAttrDO::getId).collect(Collectors.toList()); List<Long> voAttrIds = addShopGoodsVO.getGoodsAttrVOList().stream().map(AddShopGoodsAttrVO::getGoodsAttrId).collect(Collectors.toList()); //需要删除的规格ID——针对编辑时删除了规格的情况 List<Long> deleteIds = DifferentLongListUtil.getDiffrent(attrIds, voAttrIds); if(deleteIds.size()!=0){ shopGoodsAttrDAO.deleteBatchIds(deleteIds); } //先删除 ComShopGoodsAttrDO goodsAttrDO = goodsAttrService.getBaseMapper().selectById(goodsAttr.getGoodsAttrId()); ComShopGoodsAttrDO shopGoodsAttrDO = new ComShopGoodsAttrDO(); shopGoodsAttrDO.setGoodsId(id); shopGoodsAttrDO.setStoreId(shopGoodsDO.getStoreId()); shopGoodsAttrDO.setGoodsName(shopGoodsDO.getName()); if (goodsAttrDO == null) { //如果没有规格加默认 shopGoodsAttrDO.setGoodsAttr(goodsAttr.getGoodsAttr()); } else { shopGoodsAttrDO.setGoodsAttr("默认"); } shopGoodsAttrDO.setIsDefault(1); shopGoodsAttrDO.setPrice(goodsAttr.getAttrPrice()); goodsAttrDOS.add(shopGoodsAttrDO); }); if (goodsAttrDOS.size() > 0) { LambdaQueryWrapper<ComShopGoodsAttrDO> oldGoodsAttrQuery = new LambdaQueryWrapper<ComShopGoodsAttrDO>().eq(ComShopGoodsAttrDO::getGoodsId, id); //删除旧商品规格,再行添加 goodsAttrService.getBaseMapper().delete(oldGoodsAttrQuery); goodsAttrService.saveBatch(goodsAttrDOS); addShopGoodsVO.getGoodsAttrVOList().forEach(goodsAttr -> { ComShopGoodsAttrDO comShopGoodsAttrDO = shopGoodsAttrDAO.selectById(goodsAttr.getGoodsAttrId()); if(comShopGoodsAttrDO!=null){ comShopGoodsAttrDO.setPrice(goodsAttr.getAttrPrice()); comShopGoodsAttrDO.setGoodsAttr(goodsAttr.getGoodsAttr()); shopGoodsAttrDAO.updateById(comShopGoodsAttrDO); }else{ comShopGoodsAttrDO = new ComShopGoodsAttrDO(); comShopGoodsAttrDO.setGoodsId(id); comShopGoodsAttrDO.setStoreId(addShopGoodsVO.getStoreId()); comShopGoodsAttrDO.setGoodsName(addShopGoodsVO.getName()); comShopGoodsAttrDO.setGoodsAttr(goodsAttr.getGoodsAttr()); comShopGoodsAttrDO.setAttrPic(addShopGoodsVO.getGoodsPic()); comShopGoodsAttrDO.setIsDefault(1); comShopGoodsAttrDO.setPrice(goodsAttr.getAttrPrice()); shopGoodsAttrDAO.insert(comShopGoodsAttrDO); } }); } return R.ok(); } springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComShopOrderServiceImpl.java
@@ -559,8 +559,13 @@ return R.fail("订单不存在"); } if(!(comShopOrderDO.getStatus()==2) || !(comShopOrderDO.getDeleteStatus()==1)){ || !(comShopOrderDO.getDeliveryStatus()==1)){ return R.fail("订单发货失败,订单状态不允许发货"); } ComShopStoreDO storeDO = comShopStoreDAO.selectById(comShopOrderDO.getStoreId()); if(storeDO.getDeliveryType()!=2){ return R.fail("该商家不支持通过快递物流发货"); } comShopOrderDO.setDeliveryStatus(2); comShopOrderDO.setDeliveryType(2); @@ -580,11 +585,17 @@ if(comShopOrderDO==null){ return R.fail("订单不存在"); } if(!(comShopOrderDO.getStatus()==2)){ if(!(comShopOrderDO.getStatus()==2) || !(comShopOrderDO.getDeliveryStatus()==1)){ return R.fail("当前订单不能配送"); } ComShopStoreDO storeDO = comShopStoreDAO.selectById(comShopOrderDO.getStoreId()); if(storeDO.getDeliveryType()!=1){ return R.fail("该商家不支持通过商家配送"); } comShopOrderDO.setDeliveryStatus(4); comShopOrderDO.setDeliveryType(1); comShopOrderDO.setStatus(3); int updated = comShopOrderDAO.updateById(comShopOrderDO); if(updated==1){ return R.ok("开始配送"); @@ -601,6 +612,10 @@ if(!(comShopOrderDO.getDeliveryStatus() == 4)){ return R.fail("订单还未开始配送"); } if(!(comShopOrderDO.getStatus() == 3)){ return R.fail("订单还未发货"); } comShopOrderDO.setStatus(4); comShopOrderDO.setDeliveryStatus(5); int updated = comShopOrderDAO.updateById(comShopOrderDO); if(updated==1){ @@ -612,7 +627,7 @@ @Override public R shopOrderExportData(ComShopOrderExportDTO comShopOrderExportDTO) { Page page = new Page(); page.setSize(1000); page.setSize(10000); page.setCurrent(1); IPage<ExcelShopOrderDTO> excelShopOrderDTO = comShopOrderDAO.selectOrderExport(page, comShopOrderExportDTO); return R.ok(excelShopOrderDTO.getRecords()); @@ -621,7 +636,7 @@ @Override public R shopOrderFundsExportData(ComShopFundsExportDTO comShopFundsExportDTO) { Page page = new Page(); page.setSize(1000); page.setSize(10000); page.setCurrent(1); IPage<ExcelShopFundsDTO> excelShopFundsDTO = comShopOrderDAO.selectFundsExport(page, comShopFundsExportDTO); return R.ok(excelShopFundsDTO.getRecords()); springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComShopStoreServiceImpl.java
@@ -201,7 +201,7 @@ public R getOneInfo(Long id) { ComShopStoreDO comShopStoreDO = this.baseMapper.selectById(id); if (comShopStoreDO == null) { R.fail(500, "商铺不存在"); return R.fail(500, "商铺不存在"); } ShopStoreVO shopStoreVO = new ShopStoreVO(); BeanUtils.copyProperties(comShopStoreDO, shopStoreVO); @@ -212,7 +212,7 @@ public R getUserStoreInfo(Long userId) { ComShopStoreDO comShopStoreDO = this.baseMapper.selectOne(new LambdaQueryWrapper<ComShopStoreDO>().eq(ComShopStoreDO::getDeleteStatus, 1).eq(ComShopStoreDO::getSysUserId, userId)); if (comShopStoreDO == null) { R.fail(500, "商铺不存在"); return R.fail(500, "商铺不存在"); } ShopStoreVO shopStoreVO = new ShopStoreVO(); BeanUtils.copyProperties(comShopStoreDO, shopStoreVO); springcloud_k8s_panzhihuazhihuishequ/shop_backstage/src/main/java/com/panzhihua/shop_backstage/api/LoginApi.java
@@ -2,6 +2,7 @@ import com.alibaba.fastjson.JSONObject; import com.panzhihua.common.controller.BaseController; import com.panzhihua.common.model.vos.LoginReturnVO; import com.panzhihua.common.model.vos.LoginUserInfoVO; import com.panzhihua.common.model.vos.R; import com.panzhihua.common.model.vos.shop.LoginStoreUserInfoVO; @@ -34,7 +35,7 @@ @Resource private CommunityService communityService; @ApiOperation(value = "商家后台登录") @ApiOperation(value = "商家后台登录", response = LoginReturnVO.class) @ShopOperLog(operType = 1) @PostMapping("login") public R login(@RequestBody LoginBody loginBody){