Jelajahi Sumber

Merge remote-tracking branch 'origin/master'

lyx 3 bulan lalu
induk
melakukan
77452d5b4a

+ 9 - 3
alien-entity/src/main/java/shop/alien/entity/second/SecondGoodsCategory.java

@@ -41,9 +41,16 @@ public class SecondGoodsCategory implements Serializable {
     @TableLogic
     private Integer deleteFlag;
 
-    @TableField(value = "created_time", fill = FieldFill.INSERT)
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @TableField("category_sort")
+    @ApiModelProperty(value = "排序")
+    private Integer categorySort;
+
+    @TableField("category_state")
+    @ApiModelProperty(value = "状态 0:显示 1:隐藏")
+    private String categoryState;
+
     @ApiModelProperty(value = "创建时间")
+    @TableField(value = "created_time", fill = FieldFill.INSERT)
     private Date createdTime;
 
     @TableField("created_user_id")
@@ -51,7 +58,6 @@ public class SecondGoodsCategory implements Serializable {
     private Integer createdUserId;
 
     @TableField(value = "updated_time", fill = FieldFill.UPDATE)
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     @ApiModelProperty(value = "修改时间")
     private Date updatedTime;
 

+ 2 - 2
alien-entity/src/main/java/shop/alien/mapper/StoreCommentMapper.java

@@ -137,7 +137,7 @@ public interface StoreCommentMapper extends BaseMapper<StoreComment> {
     @Select("SELECT " +
             "luo.*,lgbm.group_type groupBuyType,lgbm.group_name groupBuyName,lgbm.image_id groupBuyImgId " +
             "FROM life_user_order luo LEFT JOIN order_coupon_middle ocm ON luo.id = ocm.order_id LEFT JOIN life_group_buy_main lgbm ON ocm.coupon_id = lgbm.id " +
-            "WHERE luo.`status` = 7  or luo.`status` = 2 " +
+            "WHERE luo.`status` in (2,7) " +
             "AND luo.coupon_type = 2 " +
             "AND luo.delete_flag = 0 " +
             "AND luo.user_id = #{userId} " +
@@ -147,7 +147,7 @@ public interface StoreCommentMapper extends BaseMapper<StoreComment> {
     @Select("SELECT " +
             "luo.*,lgbm.group_type groupBuyType,lgbm.group_name groupBuyName,lgbm.image_id groupBuyImgId " +
             "FROM life_user_order luo LEFT JOIN order_coupon_middle ocm ON luo.id = ocm.order_id LEFT JOIN life_group_buy_main lgbm ON ocm.coupon_id = lgbm.id " +
-            "WHERE luo.`status` = 7 or luo.`status` = 2 " +
+            "WHERE luo.`status` in (2,7) " +
             "AND luo.coupon_type = 2 " +
             "AND luo.delete_flag = 0 " +
             "AND luo.user_id = #{userId} " +

+ 2 - 1
alien-entity/src/main/java/shop/alien/mapper/second/SecondGoodsCategoryMapper.java

@@ -1,6 +1,7 @@
 package shop.alien.mapper.second;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
 import shop.alien.entity.second.SecondGoodsCategory;
 
 import java.util.List;
@@ -12,5 +13,5 @@ public interface SecondGoodsCategoryMapper extends BaseMapper<SecondGoodsCategor
     /**
      * 自定义分页查询
      */
-    List<SecondGoodsCategory> querySecondGoodsByParentId(Integer parentId);
+    List<SecondGoodsCategory> querySecondGoodsByParentId(@Param("parentId") Integer parentId, @Param("categoryState") Integer categoryState);
 }

+ 17 - 2
alien-entity/src/main/resources/mapper/second/SecondGoodsCategoryMapper.xml

@@ -12,6 +12,8 @@
         <result column="created_user_id" property="createdUserId" jdbcType="INTEGER"/>
         <result column="updated_time" property="updatedTime" jdbcType="TIMESTAMP"/>
         <result column="updated_user_id" property="updatedUserId" jdbcType="INTEGER"/>
+        <result column="category_sort" property="categorySort" jdbcType="INTEGER"/>
+        <result column="category_state" property="categoryState" jdbcType="VARCHAR"/>
     </resultMap>
 
     <!-- 根据上级ID查询二手商品类别表 -->
@@ -20,7 +22,17 @@
             id,
             category_name,
             category_url,
-            parent_id
+            parent_id,
+            delete_flag,
+            created_time,
+            created_user_id,
+            updated_time,
+            updated_user_id,
+            category_sort,
+            case when category_state = 0 then '显示'
+                when category_state = 1 then '隐藏'
+                else '未知'
+            end as category_state
         FROM
             second_goods_category
         WHERE
@@ -31,6 +43,9 @@
             <if test="parentId == null or parentId == '' ">
                 AND parent_id = -1
             </if>
+            <if test="categoryState != null and categoryState != ''">
+                AND category_state = #{categoryState}
+            </if>
+        ORDER BY category_sort, created_time
     </select>
-
 </mapper>

+ 3 - 0
alien-gateway/src/main/java/shop/alien/gateway/config/JwtTokenFilter.java

@@ -80,6 +80,9 @@ public class JwtTokenFilter implements GlobalFilter, Ordered {
         if (null != skipAuthUrls && Arrays.asList(skipAuthUrls).contains(url)) {
             return allowChain(exchange, chain);
         }
+        if (null != skipAuthUrls && url.contains("/alienStore/socket/")) {
+            return chain.filter(exchange);
+        }
         if (url.startsWith("/alienStore/webjars") || url.startsWith("/alienSecond/webjars")) {
             return allowChain(exchange, chain);
         }

+ 3 - 3
alien-second/src/main/java/shop/alien/second/controller/SecondGoodsCategoryController.java

@@ -26,8 +26,8 @@ public class SecondGoodsCategoryController {
     @ApiOperation("搜索商品类型")
     @PostMapping("/querySecondGoodsByParentId")
     public R<List<SecondGoodsCategory>> querySecondGoodsByParentId(
-            @RequestParam(value = "parentId", required = false) Integer parentId) throws Exception {
-        return R.data(service.querySecondGoodsByParentId(parentId), "查询成功");
+            @RequestParam(value = "parentId", required = false) Integer parentId,
+            @RequestParam(value = "categoryState", required = false) Integer categoryState) throws Exception {
+        return R.data(service.querySecondGoodsByParentId(parentId, categoryState), "查询成功");
     }
-
 }

+ 47 - 0
alien-second/src/main/java/shop/alien/second/platform/PlatformSecondCategoryController.java

@@ -0,0 +1,47 @@
+package shop.alien.second.platform;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiSort;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.*;
+import shop.alien.entity.result.R;
+import shop.alien.entity.second.SecondGoodsCategory;
+import shop.alien.second.service.SecondGoodsCategoryService;
+
+@Slf4j
+@Api(tags = {"二手平台-商品类型"})
+@ApiSort(9)
+@CrossOrigin
+@RestController
+@RequestMapping("/second/goodsCategory")
+@RequiredArgsConstructor
+public class PlatformSecondCategoryController {
+
+    private final SecondGoodsCategoryService service;
+
+    @ApiOperation("新增商品类型")
+    @PostMapping("/insertSecondGoodsCategory")
+    public R<String> insertSecondGoodsCategory(@RequestBody SecondGoodsCategory category) throws Exception {
+        log.info("SecondGoodsCategoryController.insertSecondGoodsCategory?category={}", category.toString());
+        Integer reporting = service.insertSecondGoodsCategory(category);
+        if (0 == reporting) {
+            return R.fail("新增商品类型失败");
+        } else {
+            return R.data("新增商品类型成功");
+        }
+    }
+
+    @ApiOperation("修改商品类型")
+    @PostMapping("/updateSecondGoodsCategory")
+    public R<String> updateSecondGoodsCategory(@RequestBody SecondGoodsCategory category) throws Exception  {
+        log.info("SecondGoodsCategoryController.updateSecondGoodsCategory?category={}", category.toString());
+        Integer reporting = service.updateSecondGoodsCategory(category);
+        if (0 == reporting) {
+            return R.fail("修改商品类型失败");
+        } else {
+            return R.data("修改商品类型成功");
+        }
+    }
+}

+ 5 - 1
alien-second/src/main/java/shop/alien/second/service/SecondGoodsCategoryService.java

@@ -15,6 +15,10 @@ public interface SecondGoodsCategoryService extends IService<SecondGoodsCategory
      * @param parentId 父ID
      * @return 分页后的屏蔽商品列
      */
-    List<SecondGoodsCategory> querySecondGoodsByParentId(Integer parentId) throws Exception;
+    List<SecondGoodsCategory> querySecondGoodsByParentId(Integer parentId, Integer categoryState) throws Exception;
+
+    Integer insertSecondGoodsCategory(SecondGoodsCategory category) throws Exception;
+
+    Integer updateSecondGoodsCategory(SecondGoodsCategory category) throws Exception;
 
 }

+ 57 - 2
alien-second/src/main/java/shop/alien/second/service/impl/SecondGoodsCategoryServiceImpl.java

@@ -1,13 +1,18 @@
 package shop.alien.second.service.impl;
 
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.util.StringUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import shop.alien.entity.second.SecondGoodsCategory;
 import shop.alien.mapper.second.SecondGoodsCategoryMapper;
 import shop.alien.second.service.SecondGoodsCategoryService;
+import shop.alien.util.common.JwtUtil;
 
 import java.util.List;
 
@@ -27,12 +32,62 @@ public class SecondGoodsCategoryServiceImpl extends ServiceImpl<SecondGoodsCateg
      * @return 是否成功保存
      */
     @Override
-    public List<SecondGoodsCategory> querySecondGoodsByParentId(Integer parentId) throws Exception {
+    public List<SecondGoodsCategory> querySecondGoodsByParentId(Integer parentId, Integer categoryState) throws Exception {
         try {
-            return mapper.querySecondGoodsByParentId(parentId);
+            return mapper.querySecondGoodsByParentId(parentId, categoryState);
         } catch (Exception e) {
             log.error("SecondGoodsCategoryServiceImpl.querySecondGoodsByParentId Error Mgs={}", e.getMessage());
             throw new Exception("查询二级商品分类失败", e);
         }
     }
+
+    @Override
+    public Integer insertSecondGoodsCategory(SecondGoodsCategory category) throws Exception {
+        try {
+            return mapper.insert(category);
+        } catch (Exception e) {
+            log.error("SecondGoodsCategoryServiceImpl.insertSecondGoodsCategory Error Mgs={}", e.getMessage());
+            throw new Exception("查询二级商品分类失败", e);
+        }
+    }
+
+    public Integer updateSecondGoodsCategory(SecondGoodsCategory category) throws Exception {
+        try {
+            JSONObject data = JwtUtil.getCurrentUserInfo();
+            String userId = null;
+            if (data != null) {
+                userId = data.getString("userId");
+            }
+            if (StringUtil.isBlank(userId)) {
+                return null;
+            }
+            LambdaUpdateWrapper<SecondGoodsCategory> wrapper = new LambdaUpdateWrapper<>();
+            wrapper.eq(SecondGoodsCategory::getId, category.getId());
+            if (StringUtils.isNotBlank(category.getCategoryName())) {
+                wrapper.set(SecondGoodsCategory::getCategoryName, category.getCategoryName());
+            }
+            if (StringUtils.isNotBlank(category.getCategoryUrl())) {
+                wrapper.set(SecondGoodsCategory::getCategoryUrl, category.getCategoryUrl());
+            }
+            if (category.getParentId() != null) {
+                wrapper.set(SecondGoodsCategory::getParentId, category.getParentId());
+            }
+            if (category.getCategorySort() != null) {
+                wrapper.set(SecondGoodsCategory::getCategorySort, category.getCategorySort());
+            }
+            if (category.getCategoryState() != null) {
+                wrapper.set(SecondGoodsCategory::getCategoryState, category.getCategoryState());
+            }
+            wrapper.set(SecondGoodsCategory::getUpdatedUserId, userId);
+            if (category.getDeleteFlag() != null) {
+                wrapper.set(SecondGoodsCategory::getDeleteFlag, category.getDeleteFlag());
+            } else {
+                wrapper.set(SecondGoodsCategory::getDeleteFlag, 0);
+            }
+            return mapper.update(null, wrapper);
+        } catch (Exception e) {
+            log.error("SecondGoodsCategoryServiceImpl.insertSecondGoodsCategory Error Mgs={}", e.getMessage());
+            throw new Exception("更新二级商品分类失败", e);
+        }
+    }
 }

+ 0 - 40
alien-store/src/main/java/shop/alien/store/service/impl/LifeCouponServiceImpl.java

@@ -233,45 +233,6 @@ public class LifeCouponServiceImpl extends ServiceImpl<LifeCouponMapper, LifeCou
         OrderCouponMiddle orderCouponMiddle = orderCouponMiddleMapper.selectOne(new LambdaQueryWrapper<OrderCouponMiddle>().eq(OrderCouponMiddle::getCouponCode, quanCode));
         if (!StringUtils.isEmpty(orderCouponMiddle)) {
             LifeUserOrder lifeUserOrder = lifeUserOrderMapper.selectOne(new LambdaQueryWrapper<LifeUserOrder>().eq(LifeUserOrder::getId, orderCouponMiddle.getOrderId()));
-            //CouponType 类型为 1:代金券 2:团购套餐
-            if (lifeUserOrder.getCouponType() == 1) {
-                orderCouponMiddle.setStatus(2);
-                orderCouponMiddle.setUsedTime(new Date());
-                orderCouponMiddleMapper.updateById(orderCouponMiddle);
-                //通过订单id查询中间表 如果该订单下所有劵都为已核销状态更改订单表状态为已核销
-                List<OrderCouponMiddle> couponMiddleList = orderCouponMiddleMapper.selectList(new LambdaQueryWrapper<OrderCouponMiddle>()
-                        .eq(OrderCouponMiddle::getOrderId,lifeUserOrder.getId()));
-                boolean isExist =  couponMiddleList.stream()
-                        .allMatch(str -> str.getStatus()==2);
-                if(isExist){
-                    lifeUserOrder.setStatus(2);
-                    lifeUserOrderMapper.updateById(lifeUserOrder);
-                }
-                // TODO 抽成比例应该从商户里取
-                BigDecimal amounts = new BigDecimal(lifeUserOrder.getFinalPrice()).multiply(new BigDecimal(100));
-                BigDecimal commission = amounts.multiply(new BigDecimal(0.04)).setScale(0, RoundingMode.HALF_UP);
-                BigDecimal money = amounts.subtract(commission);
-
-                // 插入收入明细表数据
-                StoreIncomeDetailsRecord record = new StoreIncomeDetailsRecord();
-                record.setStoreId(Integer.parseInt(storeId));
-                record.setUserOrderId(orderCouponMiddle.getId());
-                record.setIncomeType(lifeUserOrder.getCouponType());
-                record.setBusinessId(orderCouponMiddle.getCouponId());
-                record.setCommission(commission.intValue());
-                record.setMoney(money.intValue());
-                storeIncomeDetailsRecordMapper.insert(record);
-
-                // 店铺账户余额增加
-                UpdateWrapper<StoreUser> updateWrapper = new UpdateWrapper();
-                updateWrapper.eq("store_id", storeId);
-                updateWrapper.eq("delete_flag", 0);
-                updateWrapper.setSql("money = money + " + money);
-                storeUserMapper.update(null, updateWrapper);
-                resultMap.put("code", "true");
-                resultMap.put("message", "核销成功");
-
-            } else if (lifeUserOrder.getCouponType() == 2) {
                 orderCouponMiddle.setStatus(2);
                 orderCouponMiddle.setUsedTime(new Date());
                 orderCouponMiddleMapper.updateById(orderCouponMiddle);
@@ -308,7 +269,6 @@ public class LifeCouponServiceImpl extends ServiceImpl<LifeCouponMapper, LifeCou
                 storeUserMapper.update(null, updateWrapper);
                 resultMap.put("code", "true");
                 resultMap.put("message", "核销成功");
-            }
         } else {
             resultMap.put("code", "false");
             resultMap.put("message", "核销失败");

+ 1 - 2
alien-store/src/main/java/shop/alien/store/service/impl/WebAuditServiceImpl.java

@@ -81,8 +81,7 @@ public class WebAuditServiceImpl extends ServiceImpl<WebAuditMapper, WebAudit> i
     @Override
     public List<WebAuditVo> getAuditSum() {
         QueryWrapper<WebAuditVo> queryWrapper = new QueryWrapper<>();
-        List<WebAuditVo> webAudits = webAuditMapper.getAuditSum(queryWrapper);
-        return webAudits;
+        return webAuditMapper.getAuditSum(queryWrapper);
     }
 
     @Override