瀏覽代碼

bugfix-呵呵商城改版

Aslee 3 年之前
父節點
當前提交
0816c5424c

+ 5 - 0
pom.xml

@@ -161,6 +161,11 @@
             <artifactId>guava</artifactId>
             <version>29.0-jre</version>
         </dependency>
+        <dependency>
+            <groupId>com.github.tobato</groupId>
+            <artifactId>fastdfs-client</artifactId>
+            <version>1.27.2</version>
+        </dependency>
     </dependencies>
 
     <profiles>

+ 66 - 6
src/main/java/com/caimei/components/WeChatService.java

@@ -3,6 +3,7 @@ package com.caimei.components;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.caimei.model.ResponseJson;
+import com.caimei.util.FastDfsUtil;
 import com.caimei.util.HttpClientUtil;
 import com.caimei.util.HttpRequest;
 import com.caimei.util.OkHttpUtil;
@@ -15,18 +16,21 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.HttpStatus;
 import org.springframework.stereotype.Component;
+import org.springframework.web.multipart.MultipartFile;
 
+import javax.annotation.Resource;
 import javax.crypto.Cipher;
 import javax.crypto.spec.IvParameterSpec;
 import javax.crypto.spec.SecretKeySpec;
-import java.io.ByteArrayInputStream;
-import java.io.FileOutputStream;
+import java.io.*;
 import java.nio.Buffer;
+import java.nio.charset.StandardCharsets;
 import java.security.AlgorithmParameters;
 import java.security.Security;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Optional;
+import java.util.UUID;
 
 /**
  * 微信 服务工具类
@@ -42,6 +46,14 @@ public class WeChatService {
     private String heHeAppId;
     @Value("${wx.AppSecret}")
     private String heHeAppSecret;
+    @Value("${caimei.cloudApi}")
+    private String cloudApi;
+    @Value("${spring.profiles.active}")
+    private String profile;
+    @Value("${caimei.imageDomain}")
+    private String imageDomain;
+    @Resource
+    private FastDfsUtil fastDfsUtil;
 
     private RedisService redisService;
     @Autowired
@@ -188,7 +200,7 @@ public class WeChatService {
         Map<String, Object> map = JSONObject.parseObject(result, Map.class);
         access_token = (String) map.get("access_token");
         // 将token存入redis, access_token的有效期目前为2个小时(redis存1.5小时)
-        redisService.set("access_token:"+heHeAppId, access_token, 5400L);
+        redisService.set("access_token:"+heHeAppId, access_token, 1800L);
         return access_token;
     }
 
@@ -218,9 +230,9 @@ public class WeChatService {
     /**
      * 根据accessToken生成小程序二维码
      */
-    public String generateWxacode(String access_token,String params) throws Exception {
+    public String generateWxacodeBySelf(String access_token,String params) throws Exception {
         String requestUrl = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + access_token;
-        ByteArrayInputStream inputStream = HttpClientUtil.sendPost(requestUrl, params);
+        /*ByteArrayInputStream inputStream = HttpClientUtil.sendPost(requestUrl, params);
         FileOutputStream outputStream = new FileOutputStream("D:/123.png");
         int i = 0;
         byte[] buffer = new byte[200];
@@ -229,7 +241,7 @@ public class WeChatService {
         }
         outputStream.flush();
         outputStream.close();
-        inputStream.close();
+        inputStream.close();*/
         // 成功时微信服务直接返回小程序码的二进制数据,字节数组的长度会很大(大概是60000多)
         /*if (entity.getStatusCode() != HttpStatus.OK || buffer == null || buffer.length < 200) {
             log.error("请求获取小程序码失败, response: {}", Optional.ofNullable(buffer).map(String::new).orElse("response is null"));
@@ -238,5 +250,53 @@ public class WeChatService {
         return "success";
     }
 
+    /**
+     * 根据accessToken生成小程序二维码
+     */
+    public ResponseJson<String> generateWxacode(String access_token,String params) throws Exception {
+        String requestUrl = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + access_token;
+        ByteArrayInputStream inputStream = HttpClientUtil.sendPost(requestUrl, params);
+        try {
+            String fileUrl = null;
+            String url = saveFile(inputStream);
+            fileUrl = imageDomain + "/" + url;
+            log.info("【图片上传】>>>>>>>>>>>>>>>>上传成功:" + fileUrl);
+            return ResponseJson.success(fileUrl);
+        } catch (IOException e) {
+            log.error("【图片上传】>>>>>>>>>>>>>>>>上传失败:" + e);
+            return ResponseJson.error("图片上传失败", null);
+        }
+    }
+
 
+    /**
+     * 保存文件到FastDFS
+     */
+    private String saveFile(ByteArrayInputStream inputStream) throws IOException {
+        String randomStr = UUID.randomUUID().toString();
+        String name = ".jpeg";
+        // 图片暂存本地服务器路径
+        String filePath = "/mnt/newdatadrive/data/runtime/jar-instance/mall2c/tempImage/";
+        if ("dev".equals(profile)){
+            filePath = "D:\\";
+        }
+        filePath += randomStr + name;
+        FileOutputStream outputStream = new FileOutputStream(filePath);
+        int i = 0;
+        byte[] buffer = new byte[200];
+        while ((i = inputStream.read(buffer)) != -1) {
+            outputStream.write(buffer, 0, i);
+        }
+        outputStream.flush();
+        outputStream.close();
+        inputStream.close();
+        // 临时图片
+        File tempFile = new File(filePath);
+        log.info("【图片上传】>>>>>>>>>>>>>>>>图片临时路径:" + filePath);
+        String fileUrl = fastDfsUtil.uploadFile(filePath);
+        // 删除临时图片
+        boolean delete = tempFile.delete();
+        log.info("【图片上传】>>>>>>>>>>>>>>>>删除临时图片:" + delete);
+        return fileUrl;
+    }
 }

+ 22 - 6
src/main/java/com/caimei/controller/HeHeApi.java

@@ -11,11 +11,21 @@ import com.caimei.util.OkHttpUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.protocol.HttpContext;
+import org.apache.http.util.EntityUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.*;
 import redis.clients.jedis.ZParams;
 
+import java.net.URI;
 import java.util.Map;
 
 /**
@@ -59,6 +69,13 @@ public class HeHeApi {
         return getResponseJson(parameters);
     }
 
+    @ApiOperation("获取首页微信群二维码")
+    @GetMapping("/group/qrCode")
+    public String getGroupQrCode() throws Exception {
+        String url = cloudApi + "/user/he/group/qrCode";
+        return HttpRequest.sendGet(url);
+    }
+
     @ApiOperation("获取token")
     @GetMapping("/access/token")
     public ResponseJson<String> getAccessToken() throws Exception {
@@ -66,14 +83,13 @@ public class HeHeApi {
         return ResponseJson.success(accessToken);
     }
 
+
     @ApiOperation("获取小程序二维码图片")
-    @GetMapping("/wxacode/generate")
-    public ResponseJson<String> getWxImage() throws Exception {
+    @PostMapping("/wxacode")
+    public ResponseJson<String> generateWxacode(@RequestBody String params) throws Exception {
         String accessToken = weChatService.getAccessToken();
-        JSONObject params = new JSONObject();
-        params.put("scene", "yanxuanmeixue");
-        String result = weChatService.generateWxacode(accessToken, params.toString());
-        return ResponseJson.success(result);
+        ResponseJson<String> result = weChatService.generateWxacode(accessToken, params);
+        return result;
     }
 
     private ResponseJson<String> getResponseJson(String parameters) {

+ 4 - 5
src/main/java/com/caimei/controller/OrderApi.java

@@ -210,12 +210,11 @@ public class OrderApi {
     }
 
     @ApiOperation("订单分享")
-    @ApiImplicitParams({
-            @ApiImplicitParam(name = "orderId", required = false, value = "订单id"),
-            @ApiImplicitParam(name = "userId", required = false, value = "用户id")
-    })
+    @ApiImplicitParam(name = "paramsMap", required = false, value = "orderId:订单id;userId:用户id")
     @PostMapping("/share")
-    public ResponseJson shareOrder(Integer orderId, Integer userId) {
+    public ResponseJson shareOrder(@RequestBody Map<String,Integer> paramsMap) {
+        Integer orderId = paramsMap.get("orderId");
+        Integer userId = paramsMap.get("userId");
         if (null == orderId || null == userId) {
             return ResponseJson.error("参数异常");
         }

+ 4 - 23
src/main/java/com/caimei/controller/ProductApi.java

@@ -37,8 +37,9 @@ public class ProductApi {
 
     @ApiOperation("轮播图")
     @GetMapping("/carousel")
-    public ResponseJson<List<CmHeHeImageVo>> carouselFigure() {
-        return productService.carouselFigure();
+    public String carouselFigure() throws Exception {
+        String url = cloudApi + "/commodity/hehe/home/carousel";
+        return HttpRequest.sendGet(url);
     }
 
     @ApiOperation("首页楼层")
@@ -150,27 +151,7 @@ public class ProductApi {
     @ApiOperation("分类列表")
     @GetMapping("/classify")
     public String getClassify() throws Exception {
-        String url = cloudApi + "/commodity/classify?typeSort=3&mallType=2";
+        String url = cloudApi + "/commodity/classify?typeSort=3&mallType=2&source=crm";
         return HttpRequest.sendGet(url);
     }
-
-    /*@ApiOperation("二级分类列表")
-    @ApiImplicitParam(name = "bigTypeId", value = "一级分类Id", required = true)
-    @GetMapping("/type/second")
-    public String getSmallTypeSelect(Integer bigTypeId) throws Exception {
-        String url = cloudApi + "/commodity/type/second?bigTypeId=" + bigTypeId;
-        return HttpRequest.sendGet(url);
-    }*/
-
-    private ResponseJson<String> getResponseJson(String parameters) {
-        JSONObject object = JSONObject.parseObject(parameters);
-        if (null != object) {
-            Integer code = object.getInteger("code");
-            String msg = object.getString("msg");
-            String data = object.getString("data");
-            return ResponseJson.success(code, msg, data);
-        } else {
-            return ResponseJson.success(null);
-        }
-    }
 }

+ 2 - 155
src/main/java/com/caimei/mapper/ProductMapper.java

@@ -25,23 +25,6 @@ public interface ProductMapper {
      */
     List<CmHeHeImageVo> findAllImage();
 
-    /**
-     * 查询商品
-     *
-     * @param productName
-     * @return
-     */
-    List<ProductVo> findProductList(@Param("productName") String productName);
-
-    /**
-     * 查询楼层商品
-     *
-     * @param productName
-     * @param limitNum
-     * @return
-     */
-    List<ProductVo> findFloorProductList(@Param("floorId") Integer floorId, @Param("productName") String productName, @Param("limitNum") Integer limitNum);
-
     /**
      * 查询进行中的活动
      *
@@ -67,140 +50,6 @@ public interface ProductMapper {
      */
     ProductDetailsVo findProductByProductId(Integer productId);
 
-    /**
-     * 查询所有的商品图片
-     *
-     * @param productId
-     * @return
-     */
-    List<String> findProductImages(Integer productId);
-
-    /**
-     * 查询详情信息
-     *
-     * @param productId
-     * @return
-     */
-    ProductDetailInfoPo findProductDetail(Integer productId);
-
-    /**
-     * 查询分类名称
-     *
-     * @param bigTypeId
-     * @param smallTypeId
-     * @param tinyTypeId
-     * @return
-     */
-    String findTypeName(@Param("bigTypeId") Integer bigTypeId, @Param("smallTypeId") Integer smallTypeId, @Param("tinyTypeId") Integer tinyTypeId);
-
-    /**
-     * 查询品牌名称
-     *
-     * @param brandId
-     * @return
-     */
-    String findBrandName(Integer brandId);
-
-    /**
-     * 查询相关参数
-     *
-     * @param productId
-     * @return
-     */
-    List<RelatedParametersVo> findParameters(Integer productId);
-
-    /**
-     * 查询历史记录
-     *
-     * @param userId 用户id
-     * @param name   搜索关键词
-     * @return
-     */
-    Integer findSearchHistory(@Param("userId") Integer userId, @Param("name") String name);
-
-    /**
-     * 修改关键词时间
-     *
-     * @param recordId
-     */
-    void updateHistoryByDate(Integer recordId);
-
-    /**
-     * 保存搜索历史记录
-     *
-     * @param history
-     */
-    void insertSearchHistory(UserSearchHistoryPo history);
-
-    /**
-     * 查询搜索历史记录
-     *
-     * @param userId
-     * @return
-     */
-    List<String> searchHistory(Integer userId);
-
-    /**
-     * 删除多余的历史记录
-     *
-     * @param userId
-     */
-    void deleteHistoryByUserId(Integer userId);
-
-    /**
-     * 删除历史记录
-     *
-     * @param userId
-     */
-    void deleteHistory(Integer userId);
-
-    /**
-     * 查询分销者下所有活动
-     *
-     * @param userId
-     * @return
-     */
-    List<HeHeActivityVo> findActivityAll(Integer userId);
-
-    /**
-     * 查询活动详情图片
-     *
-     * @param activityId
-     * @return
-     */
-    String findActivityById(Integer activityId);
-
-    /**
-     * 查询活动商品
-     *
-     * @param userId     分销者id
-     * @param activityId 活动id
-     * @return
-     */
-    List<ProductVo> findActivityProduct(@Param("userId") Integer userId, @Param("activityId") Integer activityId);
-
-
-    /**
-     * 获取所有商品楼层
-     * @return
-     */
-    List<FloorVo> findAllFloor();
-
-
-
-    FloorVo findFloorById(Integer floorId);
-
-    /**
-     * 查找全商城商品都可参加的优惠券数量
-     * @return
-     */
-    Integer findAllProductCouponCount();
-
-    /**
-     * 查找部分商品可参加的优惠券数量
-     * @return
-     */
-    Integer findPartProductCounponCount(Integer productId);
 
     /**
      * 查找商品内部优惠折扣
@@ -212,12 +61,10 @@ public interface ProductMapper {
 
     /**
      * 查找拼团商品
-     * @param productID
+     * @param productId
      * @return
      */
-    CmHeheCollageProductPo findCollageProduct(Integer productID);
-
-    Integer findProductBuyNum(@Param("productId") Integer productId, @Param("userId") Integer userId);
+    CmHeheCollageProductPo findCollageProduct(Integer productId);
 
     /**
      * 查找商品限时特价

+ 5 - 0
src/main/java/com/caimei/model/vo/CartProductVo.java

@@ -60,6 +60,11 @@ public class CartProductVo implements Serializable {
      */
     private Integer minBuyNumber;
 
+    /**
+     * 限购量
+     */
+    private Integer limitedNum;
+
     /**
      * 是否含税   0不含税,1含税,2未知
      */

+ 5 - 0
src/main/java/com/caimei/model/vo/CollageDetailsVo.java

@@ -88,4 +88,9 @@ public class CollageDetailsVo implements Serializable {
      * 不限购买量标识:1不限制,0限制
      */
     private Integer unlimitedFlag;
+
+    /**
+     * 能否分享订单:1可以,其他不行
+     */
+    private Integer shareFlag = 0;
 }

+ 5 - 0
src/main/java/com/caimei/model/vo/OrderVo.java

@@ -270,5 +270,10 @@ public class OrderVo implements Serializable {
      */
     private String updateDate;
 
+    /**
+     * 能否分享订单:1可以,其他不行
+     */
+    private Integer shareFlag = 0;
+
     private static final long serialVersionUID = 1L;
 }

+ 0 - 77
src/main/java/com/caimei/service/ProductService.java

@@ -23,81 +23,4 @@ public interface ProductService {
      * @return
      */
     ResponseJson<List<CmHeHeImageVo>> carouselFigure();
-
-/*    *//**
-     * 商品列表
-     *
-     * @param name     商品名称
-     * @param userId   用户id
-     * @param pageNum
-     * @param pageSize
-     * @return
-     *//*
-    ResponseJson<PageInfo<ProductVo>> productList(String name, Integer userId, Integer pageNum, Integer pageSize);
-
-    *//**
-     * 商品详情
-     *
-     * @param productId 商品id
-     * @return
-     *//*
-    ResponseJson<ProductVo> productDetails(Integer productId, Integer userId);
-
-    *//**
-     * 商品搜索历史记录
-     *
-     * @param userId 用户id
-     * @return
-     *//*
-    ResponseJson<List<String>> searchHistory(Integer userId);
-
-    *//**
-     * 删除搜索历史记录
-     *
-     * @param userId 用户id
-     * @return
-     *//*
-    ResponseJson<String> deleteHistory(Integer userId);
-
-    *//**
-     * 活动专区
-     *
-     * @param userId   分销者id
-     * @param pageNum
-     * @param pageSize
-     * @return
-     *//*
-    ResponseJson<PageInfo<HeHeActivityVo>> activityArea(Integer userId, Integer pageNum, Integer pageSize);
-
-    *//**
-     * 活动详情
-     *
-     * @param userId     分销者id
-     * @param activityId 活动id
-     * @param pageNum
-     * @param pageSize
-     * @return
-     *//*
-    ResponseJson<Map<String, Object>> activityDetails(Integer userId, Integer activityId, Integer pageNum, Integer pageSize);
-
-
-    *//**
-     * 商品楼层
-     * @return
-     *//*
-    ResponseJson<List<FloorVo>> productFloor(Integer userId);*/
-
-    /**
-     * 楼层详情
-     *
-     * @param floorId
-     * @param productName
-     * @return
-     */
-//    ResponseJson<PageInfo<ProductVo>> floorDetail(Integer floorId, Integer userId, String productName, Integer pageNum, Integer pageSize);
-
-    /**
-     * 设置商品详情
-     */
-//    void setProductDetails(ProductVo product, Integer userId);
 }

+ 12 - 2
src/main/java/com/caimei/service/impl/OrderServiceImpl.java

@@ -151,6 +151,11 @@ public class OrderServiceImpl implements OrderService {
         order.setExpensesOfTaxation(expensesOfTaxation);
         order.setReturnedNum(returnedNumTotal);
         order.setActualCancelNum(actualCancelNumTotal);
+        // 查询该订单是否已有分享记录
+        Integer shareRecordCount = couponMapper.getShareRecordCount(orderId);
+        if (0 == shareRecordCount) {
+            order.setShareFlag(1);
+        }
         //删除运费商品
         shopOrderList.removeIf(student -> 998 == student.getShopId());
         List<DiscernReceiptVo> discernReceiptList = getDiscernReceipt(order);
@@ -297,7 +302,7 @@ public class OrderServiceImpl implements OrderService {
         Integer receiveCouponId = orderMapper.findOrderCoupon(orderId);
         ReceiveCouponPo receiveCoupon = couponMapper.getReceiveCouponById(receiveCouponId);
         if (null != receiveCoupon) {
-            if (2 == receiveCoupon.getSource()) {
+            if (1 == receiveCoupon.getSource() || 2 == receiveCoupon.getSource()) {
                 // 取消订单回退优惠券
                 orderMapper.revertCoupon(receiveCouponId);
             }
@@ -449,6 +454,11 @@ public class OrderServiceImpl implements OrderService {
             }
             collageDetails.setPrice(product.getPrice());
             collageDetails.setNormalPrice(product.getNormalPrice());
+            // 查询该订单是否已有分享记录
+            Integer shareRecordCount = couponMapper.getShareRecordCount(orderId);
+            if (0 == shareRecordCount) {
+                collageDetails.setShareFlag(1);
+            }
         }
         return ResponseJson.success(collageDetails);
     }
@@ -459,7 +469,7 @@ public class OrderServiceImpl implements OrderService {
         Integer shareRecordCount = couponMapper.getShareRecordCount(orderId);
         if (0 == shareRecordCount) {
             // 只能获得一次优惠券领取资格
-            List<Integer> couponIds = couponMapper.getCurrentCouponIds(5);
+            List<Integer> couponIds = couponMapper.getCurrentCouponIds(6);
             CouponSharePo couponSharePo = new CouponSharePo();
             couponSharePo.setShareUserId(userId);
             couponSharePo.setOrderId(orderId);

+ 3 - 5
src/main/java/com/caimei/service/impl/OrderSubmitServiceImpl.java

@@ -379,10 +379,7 @@ public class OrderSubmitServiceImpl implements OrderSubmitService {
         Integer couponShareId = (Integer) discountInfo.get("couponShareId");
         if (null != couponId && couponId > 0) {
             receiveCouponId = couponMapper.findReceiveCouponId(userId, couponId, couponShareId);
-            List<CouponVo> receiveCouponList = null;
-            if (null != receiveCouponId) {
-                receiveCouponList = couponMapper.findReceiveCouponList(userId, null, receiveCouponId, 1);
-            }else {
+            if (null == receiveCouponId) {
                 // 商品详情领券购买,提交订单时自动领券并使用
                 ReceiveCouponPo receiveCoupon = new ReceiveCouponPo();
                 receiveCoupon.setCouponId(couponId);
@@ -392,8 +389,9 @@ public class OrderSubmitServiceImpl implements OrderSubmitService {
                 receiveCoupon.setReceiveTime(new Date());
                 receiveCoupon.setDelFlag(0);
                 couponMapper.insertReceiveCoupon(receiveCoupon);
-                receiveCouponList = couponMapper.findReceiveCouponList(userId, null, receiveCoupon.getReceiveCouponId(), 1);
+                receiveCouponId = receiveCoupon.getReceiveCouponId();
             }
+            List<CouponVo> receiveCouponList = couponMapper.findReceiveCouponList(userId, null, receiveCouponId, 1);
             if (receiveCouponList == null || receiveCouponList.size() <= 0) {
                 // 设置手动回滚事务
                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();

+ 13 - 13
src/main/java/com/caimei/service/impl/ShoppingCartServiceImpl.java

@@ -112,6 +112,7 @@ public class ShoppingCartServiceImpl implements ShoppingCartService {
         } else if (null != collageProduct && null != collageFlag && 1 == collageFlag) {
             product.setCollageStatus(1);
             product.setPrice(collageProduct.getPrice());
+            product.setLimitedNum(1 == collageProduct.getUnlimitedFlag() ? 1000 : collageProduct.getLimitedNum());
         } else if (discountPrice != null) {
             // 限时特价
             product.setPrice(discountPrice);
@@ -122,9 +123,7 @@ public class ShoppingCartServiceImpl implements ShoppingCartService {
         Integer discount = productMapper.findProductDiscount(product.getProductId(), userId);
         if (null != discount && discount > 0) {
             product.setPrice(MathUtil.div(MathUtil.mul(product.getPrice(), discount), 100, 2));
-            if (product.getNormalPrice().compareTo(BigDecimal.ZERO) > 0) {
-                product.setNormalPrice(MathUtil.div(MathUtil.mul(product.getNormalPrice(), discount), 100, 2));
-            }
+            product.setNormalPrice(MathUtil.div(MathUtil.mul(product.getNormalPrice(), discount), 100, 2));
             if (null != ladderList) {
                 ladderList.forEach(ladder-> ladder.setBuyPrice((MathUtil.div(MathUtil.mul(ladder.getBuyPrice(), discount), 100, 2))));
             }
@@ -136,11 +135,9 @@ public class ShoppingCartServiceImpl implements ShoppingCartService {
             BigDecimal addedValueTax = MathUtil.div(MathUtil.mul(product.getPrice(), product.getClubTaxPoint()), BigDecimal.valueOf(100), 2);
             BigDecimal price = MathUtil.add(product.getPrice(), addedValueTax);
             product.setPrice(price);
-            if (product.getNormalPrice().compareTo(BigDecimal.ZERO) > 0) {
-                addedValueTax = MathUtil.div(MathUtil.mul(product.getNormalPrice(), product.getClubTaxPoint()), BigDecimal.valueOf(100), 2);
-                price = MathUtil.add(product.getNormalPrice(), addedValueTax);
-                product.setNormalPrice(price);
-            }
+            addedValueTax = MathUtil.div(MathUtil.mul(product.getNormalPrice(), product.getClubTaxPoint()), BigDecimal.valueOf(100), 2);
+            price = MathUtil.add(product.getNormalPrice(), addedValueTax);
+            product.setNormalPrice(price);
             if (null != ladderList) {
                 ladderList.forEach(ladder->{
                     BigDecimal ladderTax = MathUtil.div(MathUtil.mul(ladder.getBuyPrice(), product.getClubTaxPoint()), BigDecimal.valueOf(100), 2);
@@ -153,9 +150,10 @@ public class ShoppingCartServiceImpl implements ShoppingCartService {
         String[] productIdArr = {product.getProductId().toString()};
         // 用户在该商品上可领取的优惠券列表
         List<CouponVo> couponList = couponMapper.findCouponList(userId, productIdArr, registerTime, null);
+        List<CouponVo> receiveCouponList;
         if (null != userId) {
             // 用户在该商品上已领取未使用的优惠券列表
-            List<CouponVo> receiveCouponList = couponMapper.findReceiveCouponList(userId, productIdArr, null, 1);
+            receiveCouponList = couponMapper.findReceiveCouponList(userId, productIdArr, null, 1);
             couponList.addAll(receiveCouponList);
         }
         // 单价满足优惠条件的优惠券列表
@@ -165,7 +163,7 @@ public class ShoppingCartServiceImpl implements ShoppingCartService {
         if (couponList.size() > 0) {
             // 有可用优惠券
             couponList.forEach(coupon->{
-                if (1 == coupon.getNoThresholdFlag() || MathUtil.compare(product.getPrice(), coupon.getTouchPrice()) > 0) {
+                if (1 == coupon.getNoThresholdFlag() || MathUtil.compare(product.getPrice(), coupon.getTouchPrice()) >= 0) {
                     ableCouponList.add(coupon);
                 } else {
                     unableCouponList.add(coupon);
@@ -179,8 +177,10 @@ public class ShoppingCartServiceImpl implements ShoppingCartService {
                 product.setCouponPrice(MathUtil.sub(product.getPrice(), biggestCoupon.getCouponAmount()));
                 // 原价-最大优惠金额=原价券后价
                 product.setNormalCouponPrice(MathUtil.sub(product.getNormalPrice(), biggestCoupon.getCouponAmount()));
-                // 优惠券id
-                product.setCouponId(biggestCoupon.getCouponId());
+                //这张优惠券未领取才返回优惠券id显示领券购买
+                if (null != biggestCoupon.getUseStatus() && 0 == biggestCoupon.getUseStatus()) {
+                    product.setCouponId(biggestCoupon.getCouponId());
+                }
                 // 券后价标签
                 product.setCouponStatus(1);
             } else {
@@ -193,7 +193,7 @@ public class ShoppingCartServiceImpl implements ShoppingCartService {
             }
         }
         if (1 == product.getActiveStatus() || 1 == product.getCollageStatus() || 1 == product.getDiscountStatus()) {
-            if (product.getPrice().compareTo(product.getNormalPrice()) == 0) {
+            if (1 != product.getCollageStatus() && product.getPrice().compareTo(product.getNormalPrice()) == 0) {
                 // 原价与售价相同,不显示原价
                 product.setNormalPrice(BigDecimal.ZERO);
             }

+ 60 - 0
src/main/java/com/caimei/util/FastDfsUtil.java

@@ -0,0 +1,60 @@
+package com.caimei.util;
+
+import com.github.tobato.fastdfs.domain.fdfs.StorePath;
+import com.github.tobato.fastdfs.domain.proto.storage.DownloadByteArray;
+import com.github.tobato.fastdfs.service.FastFileStorageClient;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.FilenameUtils;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.io.*;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/10/25
+ */
+@Component
+public class FastDfsUtil {
+    @Resource
+    private FastFileStorageClient storageClient;
+
+
+    // 文件上传
+    public String uploadFile(String path) throws FileNotFoundException {
+        File file = new File(path);
+        InputStream input = new FileInputStream(file);
+        long size = FileUtils.sizeOf(file);
+        String name = file.getName();
+        String fileName = name.substring(name.lastIndexOf("/") + 1);
+        StorePath storePath = storageClient.uploadFile(input, size, FilenameUtils.getExtension(fileName), null);
+        return storePath.getFullPath();
+    }
+
+    // 文件上传
+    public String uploadStream(String path) throws FileNotFoundException {
+        File file = new File(path);
+        InputStream input = new FileInputStream(file);
+        long size = FileUtils.sizeOf(file);
+        String name = file.getName();
+        String fileName = name.substring(name.lastIndexOf("/") + 1);
+        StorePath storePath = storageClient.uploadFile(input, size, FilenameUtils.getExtension(fileName), null);
+        return storePath.getFullPath();
+    }
+
+    // 文件下载
+    public boolean downloadFile(String path, String downloadFilePath) throws IOException {
+        File file = new File(downloadFilePath);
+        FileOutputStream outputStream = null;
+        // fastdfs 文件读取
+        String filepath = path.substring(path.lastIndexOf("group1/") + 7);
+        DownloadByteArray callback = new DownloadByteArray();
+        byte[] content = storageClient.downloadFile("group1", filepath, callback);
+        // 数据写入指定文件夹中
+        outputStream = new FileOutputStream(file);
+        outputStream.write(content);
+        return true;
+    }
+}

+ 13 - 1
src/main/resources/config/beta/application-beta.yml

@@ -50,13 +50,23 @@ logging:
 
 # swagger文档显示配置
 swagger:
-  enabled: false
+  enabled: true
 
 #自定义配置
 wx:
   AppId: wx2c3b0a7f343235b1
   AppSecret: 1bb87882ee85a0411923d7f56c7dde75
 
+#DFS配置
+fdfs:
+  so-timeout: 5000 #上传的超时时间
+  connect-timeout: 2000 #连接超时时间
+  thumb-image:             #缩略图生成参数
+    width: 150
+    height: 150
+  tracker-list:            #TrackerList参数,支持多个
+    - 172.31.165.28:22122
+
 # 新旧www服务域名
 caimei:
   oldapi: https://www-b.caimei365.com
@@ -70,3 +80,5 @@ caimei:
   delayedSplittingUrl: https://mall2c-b.caimei365.com/PayOrder/delayedSplittingCallback
   #环境
   environment: BETA
+  #图片服务器
+  imageDomain: https://img-b.caimei365.com

+ 13 - 1
src/main/resources/config/dev/application-dev.yml

@@ -55,6 +55,16 @@ wx:
   AppId: wx2c3b0a7f343235b1
   AppSecret: 1bb87882ee85a0411923d7f56c7dde75
 
+#DFS配置
+fdfs:
+  so-timeout: 5000 #上传的超时时间
+  connect-timeout: 2000 #连接超时时间
+  thumb-image:             #缩略图生成参数
+    width: 150
+    height: 150
+  tracker-list:            #TrackerList参数,支持多个
+    - 192.168.2.100:22122
+
 # 新旧www服务域名
 caimei:
   oldapi: http://localhost:8100
@@ -65,4 +75,6 @@ caimei:
   #微服务网关地址
   cloudApi: http://192.168.2.100:18002
   #延时分账异步回调地址
-  delayedSplittingUrl: https://mall2c-b.caimei365.com/PayOrder/delayedSplittingCallback
+  delayedSplittingUrl: https://mall2c-b.caimei365.com/PayOrder/delayedSplittingCallback
+  #图片服务器
+  imageDomain: http://192.168.2.100

+ 12 - 0
src/main/resources/config/prod/application-prod.yml

@@ -58,6 +58,16 @@ wx:
   AppId: wx2c3b0a7f343235b1
   AppSecret: 1bb87882ee85a0411923d7f56c7dde75
 
+#DFS配置
+fdfs:
+  so-timeout: 5000 #上传的超时时间
+  connect-timeout: 2000 #连接超时时间
+  thumb-image:             #缩略图生成参数
+    width: 150
+    height: 150
+  tracker-list:            #TrackerList参数,支持多个
+    - 172.31.165.24:22122
+
 # 新旧www服务域名
 caimei:
   oldapi: https://www.caimei365.com
@@ -69,3 +79,5 @@ caimei:
   cloudApi: https://core.caimei365.com
   #延时分账异步回调地址
   delayedSplittingUrl: https://mall2c.caimei365.com/PayOrder/delayedSplittingCallback
+  #图片服务器
+  imageDomain: https://img.caimei365.com

+ 1 - 1
src/main/resources/mapper/OrderSubmitMapper.xml

@@ -69,6 +69,7 @@
           chp.id,
           chp.productId,
           chp.price,
+          chp.price as normalPrice,
           chp.includedTax,
           chp.invoiceType,
           p.costCheckFlag AS costType,
@@ -78,7 +79,6 @@
           p.costProportional,
           p.shopID AS shopId,
           p.unit,
-          p.normalPrice,
           p.name,
           p.mainImage,
           p.splitCode,

+ 1 - 242
src/main/resources/mapper/ProductMapper.xml

@@ -14,64 +14,6 @@
             - sort DESC
     </select>
 
-    <select id="findProductList" resultType="com.caimei.model.vo.ProductVo">
-        SELECT
-        a.productId,
-        a.price,
-        a.includedTax,
-        a.invoiceType,
-        a.clubTaxPoint,
-        p.name,
-        P.unit,
-        p.mainImage
-        FROM
-        cm_hehe_product a
-        LEFT JOIN product p ON a.productId = p.productID
-        WHERE
-        a.validFlag = 1
-        <if test="productName != null and productName != ''">
-            AND p.name LIKE CONCAT('%',#{productName},'%')
-        </if>
-        ORDER BY
-        a.addTime desc
-    </select>
-
-    <select id="findFloorProductList" resultType="com.caimei.model.vo.ProductVo">
-        SELECT
-        a.productId,
-        fp.recommend,
-        a.price,
-        a.includedTax,
-        a.invoiceType,
-        a.clubTaxPoint,
-        p.name,
-        P.unit,
-        p.mainImage
-        FROM
-        cm_hehe_product a
-        left join cm_hehe_floor_product fp on a.id = fp.productId
-        LEFT JOIN product p ON a.productId = p.productID
-        left join cm_hehe_floor f on fp.floorId = f.id
-        WHERE
-        a.validFlag = 1
-        and f.status = 1
-        and fp.validFlag = 1
-        <if test="floorId != null">
-            AND fp.floorId = #{floorId}
-        </if>
-        <if test="productName != null and productName != ''">
-            AND p.name LIKE CONCAT('%',#{productName},'%')
-        </if>
-        ORDER BY
-        fp.recommend DESC,
-        - fp.sort DESC,
-        fp.addTime DESC,
-        fp.productId desc
-        <if test="limitNum != null">
-            limit #{limitNum}
-        </if>
-    </select>
-
 
     <select id="getActivityIdByProductId" resultType="integer">
         SELECT
@@ -126,183 +68,6 @@
             a.productId = #{productId}
     </select>
 
-    <select id="findProductImages" resultType="string">
-        SELECT
-            image
-        FROM
-            productimage
-        WHERE
-            productID = #{productId}
-        ORDER BY
-            mainFlag DESC
-    </select>
-
-    <select id="findProductDetail" resultType="com.caimei.model.po.ProductDetailInfoPo">
-        select
-            productDetailInfoID as productDetailInfoId,
-            productID as productId,
-            propValueAlias,
-            propValueImages,
-            detailInfo,
-            detailInfoTxt,
-            seoTitle,
-            seoKeyword,
-            seoDes,
-            serviceInfo,
-            orderInfo
-        from
-            productdetailinfo
-        where
-            productID = #{productId}
-    </select>
-
-    <select id="findTypeName" resultType="string">
-        SELECT
-            CONCAT_WS('-', b.name, s.name, t.name)
-        FROM
-            bigtype b
-                LEFT JOIN smalltype s ON s.smallTypeID = #{smallTypeId}
-                LEFT JOIN tinytype t ON t.tinyTypeID = #{tinyTypeId}
-        WHERE
-            b.bigTypeID = #{bigTypeId}
-    </select>
-
-    <select id="findBrandName" resultType="string">
-        SELECT
-            name
-        FROM
-            cm_brand
-        WHERE
-            id = #{brandId}
-          and delFlag = '0'
-          and status = '1'
-    </select>
-
-    <select id="findParameters" resultType="com.caimei.model.vo.RelatedParametersVo">
-        SELECT
-            paramsName,
-            paramsContent
-        FROM
-            cm_product_related_parameters
-        WHERE
-            productId = #{productId}
-          AND delFlag = '0'
-    </select>
-
-    <select id="findSearchHistory" resultType="integer">
-        SELECT id FROM user_search_history WHERE searchWord = #{name} AND userId = #{userId} LIMIT 1
-    </select>
-
-    <update id="updateHistoryByDate">
-        UPDATE user_search_history SET searchDate = NOW() WHERE id = #{recordId}
-    </update>
-
-    <insert id="insertSearchHistory">
-        INSERT INTO `user_search_history` (
-            `userId`, `searchWord`, `searchDate`,
-            `delFlag`
-        )
-        VALUES
-        (
-            #{userId}, #{searchWord}, #{searchDate},
-            #{delFlag}
-        )
-    </insert>
-
-    <select id="searchHistory" resultType="string">
-        SELECT
-            searchWord
-        FROM
-            user_search_history
-        WHERE
-            userId = #{userId}
-        ORDER BY
-            searchDate DESC
-        LIMIT
-            10
-    </select>
-
-    <delete id="deleteHistoryByUserId">
-        DELETE FROM user_search_history
-        WHERE userId=#{userId}
-          AND id NOT IN (
-            SELECT temp.id FROM (
-                                    SELECT id FROM user_search_history WHERE userId=#{userId} ORDER BY id DESC LIMIT 10
-                                ) AS temp
-        )
-    </delete>
-
-    <delete id="deleteHistory">
-        DELETE FROM user_search_history WHERE userId + #{userId}
-    </delete>
-
-    <select id="findActivityAll" resultType="com.caimei.model.vo.HeHeActivityVo">
-        SELECT
-            cha.id AS activityId,
-            cha.name,
-            cha.listImage,
-            cha.beginTime,
-            cha.endTime,
-            COUNT(chua.id) AS productCount
-        FROM
-            cm_hehe_user_activity chua
-                LEFT JOIN cm_hehe_activity cha ON chua.activityId = cha.id
-        WHERE
-            chua.userId = #{userId}
-          AND cha.delFlag = 0
-          AND cha.status = 1
-          AND cha.beginTime <![CDATA[ <= ]]> NOW()
-          AND cha.endTime <![CDATA[ >= ]]> NOW()
-        GROUP BY
-            cha.id
-        ORDER BY
-            cha.addTime DESC
-    </select>
-
-    <select id="findActivityById" resultType="string">
-        SELECT detailsImage FROM cm_hehe_activity WHERE id = #{activityId}
-    </select>
-
-    <select id="findActivityProduct" resultType="com.caimei.model.vo.ProductVo">
-        SELECT
-            chp.productId,
-            chp.price,
-            chp.includedTax,
-            chp.invoiceType,
-            chp.clubTaxPoint,
-            p.name,
-            P.unit,
-            p.mainImage
-        FROM
-            cm_hehe_user_activity chua
-                LEFT JOIN cm_hehe_product chp ON chua.productId = chp.productId
-                LEFT JOIN product p ON chua.productId = p.productID
-        WHERE
-            chua.userId = #{userId}
-          AND chua.activityId = #{activityId}
-    </select>
-    <select id="findAllFloor" resultType="com.caimei.model.vo.FloorVo">
-        select id as floorId,title,description from cm_hehe_floor where status = 1 order by - sort desc
-    </select>
-    <select id="findFloorById" resultType="com.caimei.model.vo.FloorVo">
-        select id as floorId,title,description from cm_hehe_floor where id = #{floorId}
-    </select>
-    <select id="findAllProductCouponCount" resultType="java.lang.Integer">
-        select count(*)
-        from cm_hehe_coupon chc
-        where chc.delFlag = 0 and chc.productType = 1
-        and if(startNowFlag = 1, true, NOW() <![CDATA[  >=  ]]> startTime)
-        and if(permanentFlag = 1, true, NOW() <![CDATA[  <=  ]]> endTime)
-    </select>
-    <select id="findPartProductCounponCount" resultType="java.lang.Integer">
-        select count(*)
-        from cm_hehe_coupon chc
-                 left join cm_hehe_coupon_product chcp on chc.id = chcp.couponId
-                 left join cm_hehe_product chp on chcp.productId = chp.id
-        where chc.delFlag = 0 and chc.productType = 2 and chp.productId = #{productId}
-          and if(startNowFlag = 1, true, NOW() <![CDATA[  >=  ]]> startTime)
-          and if(permanentFlag = 1, true, NOW() <![CDATA[  <=  ]]> endTime)
-    </select>
     <select id="findProductDiscount" resultType="java.lang.Integer">
         select chd.discount
         from cm_hehe_discount chd
@@ -316,13 +81,7 @@
     <select id="findCollageProduct" resultType="com.caimei.model.po.CmHeheCollageProductPo">
         select chcp.productId, chcp.price, chcp.limitedNum, chcp.unlimitedFlag, chcp.memberNum
         from cm_hehe_collage_product chcp
-        where chcp.productId = #{productID} and chcp.status = 1
-    </select>
-    <select id="findProductBuyNum" resultType="java.lang.Integer">
-        select ifnull(sum(cop.num),0) from cm_hehe_collage_member chcm
-            left join cm_hehe_collage chc on chcm.collageId = chc.id
-            left join cm_order_product cop on chcm.orderId = cop.orderID
-        where chc.productId = #{productId} and chcm.userId = #{userId}
+        where chcp.productId = #{productId} and chcp.status = 1
     </select>
     <select id="getDiscountPrice" resultType="java.math.BigDecimal">
         select a.discountPrice