浏览代码

Merge branch 'Joburgess' of http://git.dayaedu.com/yonge/mec into Joburgess

zouxuan 5 年之前
父节点
当前提交
52304c3bcd

+ 15 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/SellOrder.java

@@ -1,6 +1,7 @@
 package com.ym.mec.biz.dal.entity;
 
 import com.ym.mec.biz.dal.enums.AccountType;
+import com.ym.mec.biz.dal.enums.SellStatus;
 import com.ym.mec.biz.dal.enums.SellTypeEnum;
 import com.ym.mec.biz.dal.enums.StockType;
 import io.swagger.annotations.ApiModel;
@@ -155,6 +156,12 @@ public class SellOrder {
     private AccountType accountType;
 
     /**
+     * 状态
+     */
+    @ApiModelProperty(value = "状态")
+    private SellStatus status;
+
+    /**
     * 交易时间
     */
     @ApiModelProperty(value="交易时间")
@@ -422,4 +429,12 @@ public class SellOrder {
     public void setBatchNo(String batchNo) {
         this.batchNo = batchNo;
     }
+
+    public SellStatus getStatus() {
+        return status;
+    }
+
+    public void setStatus(SellStatus status) {
+        this.status = status;
+    }
 }

+ 27 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/SellStatus.java

@@ -0,0 +1,27 @@
+package com.ym.mec.biz.dal.enums;
+
+import com.ym.mec.common.enums.BaseEnum;
+
+
+public enum SellStatus implements BaseEnum<Integer, SellStatus> {
+    NORMAL(0, "正常"),
+    ONLY_RETURNED(1, "仅退货"),
+    REFUND(2, "退货退费");
+
+    private Integer code;
+    private String msg;
+
+    SellStatus(Integer code, String msg) {
+        this.code = code;
+        this.msg = msg;
+    }
+
+    public String getMsg() {
+        return msg;
+    }
+
+    @Override
+    public Integer getCode() {
+        return null;
+    }
+}

+ 8 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/SellOrderService.java

@@ -32,4 +32,12 @@ public interface SellOrderService extends BaseService<Integer, SellOrder> {
     List<SellOrder> addOrderDetail2SellOrder(List<StudentPaymentOrderDetail> orderDetails, StudentPaymentOrder studentPaymentOrder, MusicGroup musicGroup);
 
     void batchInsert(List<SellOrder> sellOrders);
+
+
+    /**
+     * 退货
+     * @param id
+     * @return
+     */
+    SellOrder refund(Integer id);
 }

+ 35 - 6
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SellOrderServiceImpl.java

@@ -10,10 +10,12 @@ import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.*;
 import com.ym.mec.biz.service.*;
 import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
 import java.util.*;
@@ -30,6 +32,8 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
     private MusicGroupDao musicGroupDao;
     @Autowired
     private SysPaymentConfigService sysPaymentConfigService;
+    @Autowired
+    private SysUserCashAccountService sysUserCashAccountService;
 
     @Override
     public BaseDAO<Integer, SellOrder> getDAO() {
@@ -128,11 +132,11 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
                 }
             }
             //库存类型
-            if(goodsStockType.equals(StockType.ALL) && accountType.equals(AccountType.INTERNAL)){
+            if (goodsStockType.equals(StockType.ALL) && accountType.equals(AccountType.INTERNAL)) {
                 sellOrder.setStockType(StockType.INTERNAL);
-            }else if(goodsStockType.equals(StockType.ALL) && accountType.equals(AccountType.EXTERNAL)){
+            } else if (goodsStockType.equals(StockType.ALL) && accountType.equals(AccountType.EXTERNAL)) {
                 sellOrder.setStockType(StockType.EXTERNAL);
-            }else {
+            } else {
                 sellOrder.setStockType(goodsStockType);
             }
             //批次号 TODO
@@ -236,11 +240,11 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
                     sellOrder.setExpectAmount(BigDecimal.ZERO);
                 }
                 //库存类型
-                if(goods.getStockType().equals(StockType.ALL) && accountType.equals(AccountType.INTERNAL)){
+                if (goods.getStockType().equals(StockType.ALL) && accountType.equals(AccountType.INTERNAL)) {
                     sellOrder.setStockType(StockType.INTERNAL);
-                }else if(goods.getStockType().equals(StockType.ALL) && accountType.equals(AccountType.EXTERNAL)){
+                } else if (goods.getStockType().equals(StockType.ALL) && accountType.equals(AccountType.EXTERNAL)) {
                     sellOrder.setStockType(StockType.EXTERNAL);
-                }else {
+                } else {
                     sellOrder.setStockType(goods.getStockType());
                 }
                 //批次号 TODO
@@ -259,4 +263,29 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
         sellOrderDao.batchInsert(sellOrders);
     }
 
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public SellOrder refund(Integer id) {
+        SellOrder sellOrder = sellOrderDao.get(id);
+
+        if (!sellOrder.getStatus().equals(SellStatus.NORMAL)) {
+            throw new BizException("当前状态不能退货,请核查");
+        }
+        if (!sellOrder.getType().equals(SellTypeEnum.SCHOOL_BUY)) {
+            throw new BizException("学校采购不能退货");
+        }
+        //1、更改销售列表状态
+        sellOrder.setStatus(SellStatus.REFUND);
+        sellOrder.setUpdateTime(new Date());
+        sellOrderDao.update(sellOrder);
+
+        //2、金额退到余额
+        if (sellOrder.getActualAmount().compareTo(BigDecimal.ZERO) > 0) {
+            sysUserCashAccountService.updateBalance(sellOrder.getUserId(), sellOrder.getActualAmount().negate(), PlatformCashAccountDetailTypeEnum.REFUNDS, "退货");
+        }
+        //3、商品退回库存 TODO
+
+        return sellOrder;
+    }
+
 }

+ 1 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentRouteOrderServiceImpl.java

@@ -195,6 +195,7 @@ public class StudentPaymentRouteOrderServiceImpl extends BaseServiceImpl<Long, S
         studentPaymentOrderDao.delete(orderId);
         studentPaymentRouteOrderDao.deleteByOrderNo(studentPaymentOrder.getOrderNo());
         sellOrderDao.deleteByOrderId(orderId);
+        //归还库存 TODO
         return true;
     }
 

+ 10 - 4
mec-biz/src/main/resources/config/mybatis/SellOrderMapper.xml

@@ -29,6 +29,7 @@
         <result column="user_id_" property="userId"/>
         <result column="payment_channel_" property="paymentChannel"/>
         <result column="mer_no_" property="merNo"/>
+        <result column="status_" property="status"/>
         <result column="sell_time_" property="sellTime"/>
         <result column="create_ime_" property="createIme"/>
         <result column="update_time_" property="updateTime"/>
@@ -37,9 +38,8 @@
     <sql id="Base_Column_List">
         <!--@mbg.generated-->
         id_, edu_teacher_id_,organ_id_, cooperation_organ_id_, trans_no_,order_id_, order_no_, expect_amount_,
-        actual_amount_,
-        balance_amount_, sell_cost_, sell_cost2_, type_, goods_id_,goods_name_, num_, user_id_, payment_channel_,
-        mer_no_, sell_time_, create_ime_, update_time_
+        actual_amount_,balance_amount_, sell_cost_, sell_cost2_, type_, goods_id_,goods_name_, num_, user_id_,
+        payment_channel_,mer_no_,batch_no_,stock_type_,account_type_,status_, sell_time_, create_ime_, update_time_
     </sql>
     <select id="get" parameterType="java.lang.Integer" resultMap="SellOrder">
         <!--@mbg.generated-->
@@ -130,6 +130,9 @@
             <if test="accountType != null">
                 account_type_ = #{accountType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
             </if>
+            <if test="status != null">
+                status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
+            </if>
             <if test="sellTime != null">
                 sell_time_ = #{sellTime},
             </if>
@@ -193,8 +196,11 @@
             <if test="cooperationOrganId != null">
                 AND so.cooperation_organ_id_ = #{cooperationOrganId}
             </if>
+            <if test="status != null">
+                AND so.status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+            </if>
             <if test="type != null">
-                AND so.type_ = #{type}
+                AND so.type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
             </if>
             <if test="receiveStatus != null and receiveStatus != ''">
                 AND spo.receive_status_ = #{receiveStatus}

+ 1 - 1
mec-student/src/main/java/com/ym/mec/student/controller/SubjectChangeController.java

@@ -48,7 +48,7 @@ public class SubjectChangeController extends BaseController {
             @ApiImplicitParam(name = "金额", value = "amount", required = true, dataType = "BigDecimal"),
             @ApiImplicitParam(name = "是否使余额", value = "isUseBalancePayment", required = true, dataType = "Boolean")
     })
-    public HttpResponseResult<Map> payChaange(Integer id, BigDecimal amount, Boolean isUseBalancePayment, Boolean isRepay) throws Exception {
+    public HttpResponseResult<Map> payChange(Integer id, BigDecimal amount, Boolean isUseBalancePayment, Boolean isRepay) throws Exception {
         SubjectChange subjectChange = subjectChangeDao.get(id);
         if (!isRepay && subjectChange.getStatus().equals(SubjectChangeStatusEnum.ING)) {
             return failed(HttpStatus.CONTINUE, "您有待支付的订单");

+ 14 - 2
mec-web/src/main/java/com/ym/mec/web/controller/AdapayController.java

@@ -19,6 +19,7 @@ import io.swagger.annotations.ApiOperation;
 import org.apache.commons.io.IOUtils;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -39,6 +40,9 @@ public class AdapayController extends BaseController {
     @Autowired
     private SysConfigDao sysConfigDao;
 
+    @Value("${spring.profiles.active:dev}")
+    private String profiles;
+
     @ApiOperation(value = "企业用户列表")
     @GetMapping("/queryPage")
     @PreAuthorize("@pcs.hasPermissions('adapay/queryPage')")
@@ -50,6 +54,9 @@ public class AdapayController extends BaseController {
     @PostMapping(value = "createMember")
     @PreAuthorize("@pcs.hasPermissions('adapay/createMember')")
     public HttpResponseResult<Map<String, Object>> createMember(HfMember member) throws Exception {
+        if (!profiles.equals("prod")) {
+            return failed("仅生产环境可用");
+        }
         if (member.getMultipartFile().isEmpty()) {
             return failed("证件压缩文件必传");
         }
@@ -75,6 +82,9 @@ public class AdapayController extends BaseController {
     @PostMapping(value = "updateMember")
     @PreAuthorize("@pcs.hasPermissions('adapay/updateMember')")
     public HttpResponseResult<Map<String, Object>> updateMember(HfMember member) throws Exception {
+        if (!profiles.equals("prod")) {
+            return failed("仅生产环境可用");
+        }
         if (member.getMultipartFile().isEmpty()) {
             return failed("证件压缩文件必传");
         }
@@ -101,6 +111,9 @@ public class AdapayController extends BaseController {
     @PostMapping(value = "createSettleAccount")
     @PreAuthorize("@pcs.hasPermissions('adapay/createSettleAccount')")
     public HttpResponseResult<Map<String, Object>> createSettleAccount(String memberId, String cardNo, String bankCode) throws Exception {
+        if (!profiles.equals("prod")) {
+            return failed("仅生产环境可用");
+        }
         try {
             return succeed(hfMemberService.createSettleAccount(memberId, cardNo, bankCode));
         } catch (Exception e) {
@@ -120,12 +133,11 @@ public class AdapayController extends BaseController {
     @GetMapping(value = "exportBill")
     @PreAuthorize("@pcs.hasPermissions('adapay/exportBill')")
     public void exportBill(Date startTime, Date endTime, HttpServletResponse response) throws Exception {
-
         long createdGte = startTime.getTime();
         long createdLte = DateUtil.getLastSecondWithDay(endTime).getTime();
         int pageIndex = 1;
         List<Map<String, Object>> data = new ArrayList<>();
-        while (true) {
+        while (profiles.equals("prod")) {
             Map<String, Object> paymentList = Payment.queryList(pageIndex, createdGte, createdLte);
             JSONArray payments = (JSONArray) paymentList.get("payments");
             if (!paymentList.get("status").equals("succeeded")) {

+ 7 - 0
mec-web/src/main/java/com/ym/mec/web/controller/SellOrderController.java

@@ -80,4 +80,11 @@ public class SellOrderController extends BaseController {
         return succeed(sellOrder);
     }
 
+    @ApiOperation("退货")
+    @PostMapping(value = "/refund")
+    @PreAuthorize("@pcs.hasPermissions('sellOrder/refund')")
+    public HttpResponseResult<SellOrder> refund(Integer id) {
+        return succeed(sellOrderService.refund(id));
+    }
+
 }