瀏覽代碼

Merge branch 'maintenance_feature'

周箭河 4 年之前
父節點
當前提交
28f25dfe5d

+ 39 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentInstrument.java

@@ -59,6 +59,18 @@ public class StudentInstrument {
     private Date endTime;
 
     /**
+     * 对应订单id
+     */
+    @ApiModelProperty(value = "订单id")
+    private Long orderId;
+
+    /**
+     * 操作人
+     */
+    @ApiModelProperty(value = "操作人")
+    private Integer operation;
+
+    /**
      * 添加时间
      */
     @ApiModelProperty(value = "添加时间")
@@ -70,6 +82,9 @@ public class StudentInstrument {
     @ApiModelProperty(value = "更新时间")
     private Date updateTime;
 
+    @ApiModelProperty(value = "删除标识 1 已删除 0 正常")
+    private Integer delFlag;
+
     @ApiModelProperty(value = "乐器名称")
     private String goodsName;
 
@@ -235,4 +250,28 @@ public class StudentInstrument {
     public void setGoodsCategoryName(String goodsCategoryName) {
         this.goodsCategoryName = goodsCategoryName;
     }
+
+    public Integer getDelFlag() {
+        return delFlag;
+    }
+
+    public void setDelFlag(Integer delFlag) {
+        this.delFlag = delFlag;
+    }
+
+    public Long getOrderId() {
+        return orderId;
+    }
+
+    public void setOrderId(Long orderId) {
+        this.orderId = orderId;
+    }
+
+    public Integer getOperation() {
+        return operation;
+    }
+
+    public void setOperation(Integer operation) {
+        this.operation = operation;
+    }
 }

+ 9 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/StudentInstrumentService.java

@@ -45,4 +45,13 @@ public interface StudentInstrumentService extends BaseService<Long, StudentInstr
      * @return
      */
     Boolean pushNotice();
+
+
+    /**
+     * 修改学生乐器
+     * @param studentInstrument
+     * @return
+     */
+    StudentInstrument updateStudentInstrument(StudentInstrument studentInstrument);
+
 }

+ 3 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SellOrderServiceImpl.java

@@ -75,7 +75,7 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
         }
 
         BigDecimal hasRouteBalance = BigDecimal.ZERO;
-        BigDecimal goodsTotalBalance = goodsTotalPrice.multiply(balance).divide(totalAmount, 2, BigDecimal.ROUND_DOWN);
+        BigDecimal goodsTotalBalance = totalAmount.compareTo(BigDecimal.ZERO) <= 0 ? BigDecimal.ZERO : goodsTotalPrice.multiply(balance).divide(totalAmount, 2, BigDecimal.ROUND_DOWN);
         AccountType accountType = sysPaymentConfigService.checkAccountType(PaymentChannelEnum.valueOf(order.getPaymentChannel()), order.getMerNos());
 
         List<SellOrder> sellOrderList = goodsService.subtractStock(goodsIds, accountType);
@@ -91,7 +91,8 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
             }
             goodsPrice = nowGoods.getDiscountPrice();
 
-            BigDecimal goodsBalance = goodsTotalBalance.multiply(goodsPrice).divide(goodsTotalPrice, 2, BigDecimal.ROUND_DOWN);
+            BigDecimal goodsBalance = goodsTotalPrice.compareTo(BigDecimal.ZERO) <= 0 ? BigDecimal.ZERO :
+                    goodsTotalBalance.multiply(goodsPrice).divide(goodsTotalPrice, 2, BigDecimal.ROUND_DOWN);
             if (i == goodsNum) {
                 goodsBalance = goodsTotalBalance.subtract(hasRouteBalance);
             }

+ 14 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentInstrumentServiceImpl.java

@@ -328,4 +328,18 @@ public class StudentInstrumentServiceImpl extends BaseServiceImpl<Long, StudentI
         }
         return true;
     }
+
+    @Override
+    public StudentInstrument updateStudentInstrument(StudentInstrument studentInstrument) {
+        Goods goods = goodsService.get(studentInstrument.getGoodsId());
+        GoodsCategory goodsCategory = goodsCategoryService.get(goods.getGoodsCategoryId());
+        studentInstrument.setGoodsCategoryId(goods.getGoodsCategoryId());
+        studentInstrument.setGoodsCategoryName(goodsCategory.getName());
+        studentInstrument.setGoodsName(goods.getName());
+        studentInstrument.setGoodsBrand(goods.getBrand());
+        studentInstrument.setSpecification(goods.getSpecification());
+        studentInstrument.setGoodsImg(goods.getImage());
+        studentInstrumentDao.update(studentInstrument);
+        return studentInstrument;
+    }
 }

+ 15 - 2
mec-biz/src/main/resources/config/mybatis/StudentInstrumentMapper.xml

@@ -13,8 +13,11 @@
         <result column="status_" property="status"/>
         <result column="start_time_" property="startTime"/>
         <result column="end_time_" property="endTime"/>
+        <result column="order_id_" property="organId"/>
+        <result column="operation_" property="operation"/>
         <result column="create_time_" property="createTime"/>
         <result column="update_time" property="updateTime"/>
+        <result column="del_flag_" property="delFlag"/>
         <result column="goods_name_" property="goodsName"/>
         <result column="specification_" property="specification"/>
         <result column="goods_brand_" property="goodsBrand"/>
@@ -37,11 +40,11 @@
         <!--@mbg.generated-->
         insert into student_instrument
         (student_id_,organ_id_,goods_id_,goods_category_id_,goods_category_name_,goods_name_,goods_brand_,specification_,goods_img_,
-        status_, start_time_, end_time_, create_time_, update_time
+        order_id_,operation_, start_time_, end_time_, create_time_, update_time
         )
         values
         (#{studentId},#{organId},#{goodsId},#{goodsCategoryId},#{goodsCategoryName},#{goodsName},#{goodsBrand},#{specification},#{goodsImg},
-        #{status}, #{startTime}, #{endTime}, NOW(), NOW()
+        #{organId},#{operation},#{status}, #{startTime}, #{endTime}, NOW(), NOW()
         )
     </insert>
     <update id="update" parameterType="com.ym.mec.biz.dal.entity.StudentInstrument">
@@ -72,6 +75,9 @@
             <if test="status != null">
                 status_ = #{status},
             </if>
+            <if test="operation != null">
+                operation_ = #{operation},
+            </if>
             <if test="startTime != null">
                 start_time_ = #{startTime},
             </if>
@@ -84,6 +90,9 @@
             <if test="updateTime != null">
                 update_time = #{updateTime},
             </if>
+            <if test="delFlag != null">
+                del_flag_ = #{delFlag},
+            </if>
         </set>
         where id_ = #{id}
     </update>
@@ -131,9 +140,13 @@
             <if test="specification != null">
                 AND si.specification_ LIKE CONCAT('%',#{specification},'%')
             </if>
+            <if test="status != null">
+                AND si.status_ = #{status}
+            </if>
             <if test="search != null">
                 AND (si.student_id_ = #{search} OR su.phone_ = #{search} OR su.username_ LIKE CONCAT('%',#{search},'%'))
             </if>
+            AND del_flag_ = 0
         </where>
     </sql>
 

+ 60 - 2
mec-web/src/main/java/com/ym/mec/web/controller/StudentInstrumentController.java

@@ -80,16 +80,74 @@ public class StudentInstrumentController extends BaseController {
         if (studentInstrument.getStudentId() == null) {
             return failed("学生id不能为空");
         }
-        if(studentInstrument.getStartTime() != null){
+        if (studentInstrument.getStartTime() != null) {
             studentInstrument.setStartTime(DateUtil.trunc(studentInstrument.getStartTime()));
         }
 
-        if(studentInstrument.getEndTime() != null){
+        if (studentInstrument.getEndTime() != null) {
             studentInstrument.setEndTime(DateUtil.getLastTimeWithDay(studentInstrument.getEndTime()));
         }
+        studentInstrument.setOperation(sysUser.getId());
         SysUser student = sysUserFeignService.queryUserById(studentInstrument.getStudentId());
         studentInstrument.setOrganId(student.getOrganId());
         return succeed(studentInstrumentService.addStudentInstrument(studentInstrument));
     }
 
+
+    @ApiOperation(value = "获取乐保信息")
+    @GetMapping("/getInfo")
+    @PreAuthorize("@pcs.hasPermissions('studentInstrument/getInfo')")
+    public HttpResponseResult<StudentInstrument> getInfo(Long id, Integer studentId) {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            return failed("用户信息获取失败");
+        }
+        StudentInstrument studentInstrument = studentInstrumentService.get(id);
+        if (studentInstrument == null || !studentInstrument.getStudentId().equals(studentId)) {
+            return failed("学生乐器信息不存在");
+        }
+        return succeed(studentInstrument);
+    }
+
+
+    @ApiOperation(value = "修改乐保信息")
+    @PostMapping("/update")
+    @PreAuthorize("@pcs.hasPermissions('studentInstrument/update')")
+    public HttpResponseResult<StudentInstrument> update(StudentInstrument studentInstrument) {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            return failed("用户信息获取失败");
+        }
+        if (studentInstrument.getStudentId() == null) {
+            return failed("学生id不能为空");
+        }
+        if (studentInstrument.getStartTime() != null) {
+            studentInstrument.setStartTime(DateUtil.trunc(studentInstrument.getStartTime()));
+        }
+
+        if (studentInstrument.getEndTime() != null) {
+            studentInstrument.setEndTime(DateUtil.getLastTimeWithDay(studentInstrument.getEndTime()));
+        }
+        studentInstrument.setOperation(sysUser.getId());
+        SysUser student = sysUserFeignService.queryUserById(studentInstrument.getStudentId());
+        studentInstrument.setOrganId(student.getOrganId());
+        return succeed(studentInstrumentService.updateStudentInstrument(studentInstrument));
+    }
+
+    @ApiOperation(value = "删除学生乐器信息")
+    @PostMapping("/del")
+    @PreAuthorize("@pcs.hasPermissions('studentInstrument/del')")
+    public HttpResponseResult<StudentInstrument> update(Long id, Integer studentId) {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            return failed("用户信息获取失败");
+        }
+        StudentInstrument studentInstrument = studentInstrumentService.get(id);
+        if (studentInstrument == null || !studentInstrument.getStudentId().equals(studentId)) {
+            return failed("学生乐器信息不存在");
+        }
+        studentInstrument.setOperation(sysUser.getId());
+        studentInstrument.setDelFlag(1);
+        return succeed(studentInstrumentService.updateStudentInstrument(studentInstrument));
+    }
 }