zouxuan 4 years ago
parent
commit
8a90808fda

+ 38 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/GoodsSellDto.java

@@ -0,0 +1,38 @@
+package com.ym.mec.biz.dal.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+
+public class GoodsSellDto{
+	@ApiModelProperty(value = "使用余额", required = false)
+	private Boolean isUseBalancePayment;
+
+	@ApiModelProperty(value = "商品列表", required = false)
+	String goodsId;
+
+	@ApiModelProperty(value = "是否重复支付", required = false)
+	private boolean isRepeatPay;
+
+	public boolean getIsRepeatPay() {
+		return isRepeatPay;
+	}
+
+	public void setIsRepeatPay(boolean repeatPay) {
+		isRepeatPay = repeatPay;
+	}
+
+	public Boolean getIsUseBalancePayment() {
+		return isUseBalancePayment;
+	}
+
+	public void setIsUseBalancePayment(Boolean useBalancePayment) {
+		isUseBalancePayment = useBalancePayment;
+	}
+
+	public String getGoodsId() {
+		return goodsId;
+	}
+
+	public void setGoodsId(String goodsId) {
+		this.goodsId = goodsId;
+	}
+}

+ 2 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/GoodsType.java

@@ -4,7 +4,8 @@ import com.ym.mec.common.enums.BaseEnum;
 
 
 public enum GoodsType implements BaseEnum<String, GoodsType> {
 public enum GoodsType implements BaseEnum<String, GoodsType> {
 
 
-	INSTRUMENT("INSTRUMENT", "乐器"), ACCESSORIES("ACCESSORIES", "辅件"),
+	INSTRUMENT("INSTRUMENT", "乐器"),
+	ACCESSORIES("ACCESSORIES", "辅件"),
 	TEACHING("TEACHING", "教材"),
 	TEACHING("TEACHING", "教材"),
 	STAFF("STAFF", "曲谱"),
 	STAFF("STAFF", "曲谱"),
 	OTHER("OTHER", "其他");
 	OTHER("OTHER", "其他");

+ 1 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/GroupType.java

@@ -10,6 +10,7 @@ public enum GroupType implements BaseEnum<String, GroupType> {
 	PRACTICE("网管课"),
 	PRACTICE("网管课"),
 	COMM("对外课程"),
 	COMM("对外课程"),
 	REPAIR("乐器维修"),
 	REPAIR("乐器维修"),
+	GOODS_SELL("商品销售"),
 	OUTORDER("外部订单");
 	OUTORDER("外部订单");
 
 
 	private String desc;
 	private String desc;

+ 1 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/OrderTypeEnum.java

@@ -16,6 +16,7 @@ public enum OrderTypeEnum implements BaseEnum<String, OrderTypeEnum> {
 	COURSE_GROUP_BUY("COURSE_GROUP_BUY","对外课程购买"),
 	COURSE_GROUP_BUY("COURSE_GROUP_BUY","对外课程购买"),
 	LUCK("LUCK", "福袋活动"),
 	LUCK("LUCK", "福袋活动"),
 	TENANT_RECHARGE("TENANT_RECHARGE","租户充值"),
 	TENANT_RECHARGE("TENANT_RECHARGE","租户充值"),
+	GOODS_SELL("GOODS_SELL","商品销售"),
 	REPAIR("REPAIR","乐器维修");
 	REPAIR("REPAIR","乐器维修");
 
 
 	private String code;
 	private String code;

+ 1 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/PlatformCashAccountDetailTypeEnum.java

@@ -13,6 +13,7 @@ public enum PlatformCashAccountDetailTypeEnum implements BaseEnum<String, Platfo
 	FILL_ACCOUNT("FILL_ACCOUNT", "人工补账"),
 	FILL_ACCOUNT("FILL_ACCOUNT", "人工补账"),
 	REFUNDS("REFUNDS", "退费"),
 	REFUNDS("REFUNDS", "退费"),
 	REWARDS("REWARDS", "奖励"),
 	REWARDS("REWARDS", "奖励"),
+	GOODS_SELL("GOODS_SELL", "商品销售"),
 	WAGE("WAGE", "工资");
 	WAGE("WAGE", "工资");
 
 
 	private String code;
 	private String code;

+ 23 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/StudentRepairService.java

@@ -1,6 +1,7 @@
 package com.ym.mec.biz.service;
 package com.ym.mec.biz.service;
 
 
 import com.ym.mec.biz.dal.dto.BasicUserDto;
 import com.ym.mec.biz.dal.dto.BasicUserDto;
+import com.ym.mec.biz.dal.dto.GoodsSellDto;
 import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
 import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
 import com.ym.mec.biz.dal.entity.StudentRepair;
 import com.ym.mec.biz.dal.entity.StudentRepair;
 import com.ym.mec.biz.dal.page.RepairStudentQueryInfo;
 import com.ym.mec.biz.dal.page.RepairStudentQueryInfo;
@@ -67,4 +68,26 @@ public interface StudentRepairService extends BaseService<Integer, StudentRepair
      * @param order
      * @param order
      */
      */
     Boolean orderCallback(StudentPaymentOrder order);
     Boolean orderCallback(StudentPaymentOrder order);
+
+    /**
+     * @describe 添加商品销售订单
+     * @apiNote 时光荏苒,认真工作的时间总是过得很快,而我、享受这一刻!
+     * @author zouxuan
+     * @date 2020/9/16
+     * @time 13:47
+     * @param goodsSellDto:
+     * @return java.util.Map
+     */
+    Map addGoodsSellOrder(GoodsSellDto goodsSellDto) throws Exception;
+
+    /**
+     * @describe 商品销售订单回调
+     * @apiNote 时光荏苒,认真工作的时间总是过得很快,而我、享受这一刻!
+     * @author zouxuan
+     * @date 2020/9/16
+     * @time 16:58
+     * @param order:
+     * @return void
+     */
+    void goodsSellorderCallback(StudentPaymentOrder order);
 }
 }

+ 4 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderServiceImpl.java

@@ -245,6 +245,8 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
             practiceGroupService.orderCallback(order);
             practiceGroupService.orderCallback(order);
         } else if (order.getType().equals(OrderTypeEnum.REPAIR)) {
         } else if (order.getType().equals(OrderTypeEnum.REPAIR)) {
             studentRepairService.orderCallback(order);
             studentRepairService.orderCallback(order);
+        } else if (order.getType().equals(OrderTypeEnum.GOODS_SELL)) {
+            studentRepairService.goodsSellorderCallback(order);
         }
         }
     }
     }
 
 
@@ -280,6 +282,8 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
                     practiceGroupService.orderCallback(order);
                     practiceGroupService.orderCallback(order);
                 } else if (order.getType().equals(OrderTypeEnum.REPAIR)) {
                 } else if (order.getType().equals(OrderTypeEnum.REPAIR)) {
                     studentRepairService.orderCallback(order);
                     studentRepairService.orderCallback(order);
+                } else if (order.getType().equals(OrderTypeEnum.GOODS_SELL)) {
+                    studentRepairService.goodsSellorderCallback(order);
                 }
                 }
             } catch (Exception e) {
             } catch (Exception e) {
                 e.printStackTrace();
                 e.printStackTrace();

+ 164 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRepairServiceImpl.java

@@ -9,6 +9,7 @@ import com.ym.mec.biz.dal.dao.StudentDao;
 import com.ym.mec.biz.dal.dao.StudentRepairDao;
 import com.ym.mec.biz.dal.dao.StudentRepairDao;
 import com.ym.mec.biz.dal.dao.SysConfigDao;
 import com.ym.mec.biz.dal.dao.SysConfigDao;
 import com.ym.mec.biz.dal.dto.BasicUserDto;
 import com.ym.mec.biz.dal.dto.BasicUserDto;
+import com.ym.mec.biz.dal.dto.GoodsSellDto;
 import com.ym.mec.biz.dal.dto.RepairGoodsDto;
 import com.ym.mec.biz.dal.dto.RepairGoodsDto;
 import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.*;
 import com.ym.mec.biz.dal.enums.*;
@@ -49,6 +50,8 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
     @Autowired
     @Autowired
     private StudentPaymentOrderService studentPaymentOrderService;
     private StudentPaymentOrderService studentPaymentOrderService;
     @Autowired
     @Autowired
+    private StudentPaymentOrderDetailService studentPaymentOrderDetailService;
+    @Autowired
     private SysUserCashAccountService sysUserCashAccountService;
     private SysUserCashAccountService sysUserCashAccountService;
     @Autowired
     @Autowired
     private SysUserCashAccountDetailService sysUserCashAccountDetailService;
     private SysUserCashAccountDetailService sysUserCashAccountDetailService;
@@ -57,6 +60,8 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
     @Autowired
     @Autowired
     private StudentDao studentDao;
     private StudentDao studentDao;
     @Autowired
     @Autowired
+    private GoodsService goodsService;
+    @Autowired
     private StudentPaymentRouteOrderService studentPaymentRouteOrderService;
     private StudentPaymentRouteOrderService studentPaymentRouteOrderService;
 
 
     @Override
     @Override
@@ -93,6 +98,110 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
 
 
     @Override
     @Override
     @Transactional(rollbackFor = Exception.class)
     @Transactional(rollbackFor = Exception.class)
+    public Map addGoodsSellOrder(GoodsSellDto goodsSellDto) throws Exception {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            throw new BizException("请登录");
+        }
+        Integer studentId = sysUser.getId();
+        String goodsId = goodsSellDto.getGoodsId();
+        if(StringUtils.isEmpty(goodsId)){
+            throw new BizException("请选择需要购买的商品");
+        }
+        if(studentId == null){
+            throw new BizException("请指定学员");
+        }
+        studentDao.lockUser(studentId);
+        SysUser student = sysUserFeignService.queryUserById(studentId);
+        String orderNo = idGeneratorService.generatorId("payment") + "";
+        List<Goods> goods = goodsService.findGoodsByIds(goodsId);
+        BigDecimal amount = goods.stream().map(e -> e.getGroupPurchasePrice()).reduce(BigDecimal.ZERO, BigDecimal::add);
+
+        StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder();
+        studentPaymentOrder.setUserId(studentId);
+        studentPaymentOrder.setGroupType(GroupType.GOODS_SELL);
+        studentPaymentOrder.setOrderNo(orderNo);
+        studentPaymentOrder.setType(OrderTypeEnum.GOODS_SELL);
+        studentPaymentOrder.setExpectAmount(amount);
+        studentPaymentOrder.setActualAmount(amount);
+        studentPaymentOrder.setStatus(DealStatusEnum.ING);
+        studentPaymentOrder.setOrganId(student.getOrganId());
+        studentPaymentOrder.setRoutingOrganId(student.getOrganId());
+        studentPaymentOrderService.insert(studentPaymentOrder);
+
+        Map<GoodsType, List<Goods>> collect = goods.stream().collect(Collectors.groupingBy(Goods::getType));
+        List<StudentPaymentOrderDetail> studentPaymentOrderDetailList = new ArrayList<>();
+        goods.forEach(e->{
+            StudentPaymentOrderDetail studentPaymentOrderDetail = new StudentPaymentOrderDetail();
+            studentPaymentOrderDetail.setRemitFee(BigDecimal.ZERO);
+            OrderDetailTypeEnum type = null;
+            if (e.getType() == GoodsType.INSTRUMENT) {
+                type = OrderDetailTypeEnum.MUSICAL;
+            } else if (e.getType() == GoodsType.ACCESSORIES) {
+                type = OrderDetailTypeEnum.ACCESSORIES;
+            } else if (e.getType() == GoodsType.OTHER) {
+                type = OrderDetailTypeEnum.TEACHING;
+            }
+            studentPaymentOrderDetail.setType(type);
+            studentPaymentOrderDetail.setPrice(e.getGroupPurchasePrice());
+            String join = StringUtils.join(collect.get(e.getType()).stream().map(g -> g.getId()).collect(Collectors.toList()), ",");
+            studentPaymentOrderDetail.setGoodsIdList(join);
+            studentPaymentOrderDetail.setPaymentOrderId(studentPaymentOrder.getId());
+            studentPaymentOrderDetail.setKitGroupPurchaseType(KitGroupPurchaseTypeEnum.GROUP);
+            studentPaymentOrderDetailList.add(studentPaymentOrderDetail);
+        });
+        studentPaymentOrderDetailService.batchAdd(studentPaymentOrderDetailList);
+
+        studentPaymentOrder.setVersion(0);
+        BigDecimal balance = BigDecimal.ZERO;
+        if (goodsSellDto.getIsUseBalancePayment() && amount.compareTo(BigDecimal.ZERO) > 0) {
+            SysUserCashAccount userCashAccount = sysUserCashAccountService.getLocked(studentId);
+            if (userCashAccount == null) {
+                throw new BizException("用户账户找不到");
+            }
+            if (userCashAccount.getBalance() != null && userCashAccount.getBalance().compareTo(BigDecimal.ZERO) > 0) {
+                balance = amount.compareTo(userCashAccount.getBalance()) >= 0 ? userCashAccount.getBalance() : amount;
+                amount = amount.subtract(balance);
+                studentPaymentOrder.setActualAmount(amount);
+                studentPaymentOrder.setBalancePaymentAmount(balance);
+                sysUserCashAccountService.updateBalance(studentId, balance.negate(), PlatformCashAccountDetailTypeEnum.PAY_FEE, "商品销售");
+            }
+        }
+        studentPaymentOrderService.update(studentPaymentOrder);
+        studentPaymentOrder.setVersion(studentPaymentOrder.getVersion() + 1);
+
+        if (amount.compareTo(BigDecimal.ZERO) == 0) {
+            studentPaymentRouteOrderService.addRouteOrder(orderNo, student.getOrganId(), balance);
+            Map<String, String> notifyMap = new HashMap<>();
+            notifyMap.put("tradeState", "1");
+            notifyMap.put("merOrderNo", studentPaymentOrder.getOrderNo());
+            studentPaymentOrderService.updateOrder(notifyMap);
+            notifyMap.put("orderNo", orderNo);
+            return notifyMap;
+        }
+
+        String baseApiUrl = sysConfigDao.findConfigValue(SysConfigService.BASE_API_URL);
+
+        Map payMap = payService.getPayMap(
+                amount,
+                balance,
+                orderNo,
+                baseApiUrl + "/api-student/studentOrder/notify",
+                baseApiUrl + "/api-student/studentOrder/paymentResult?type=edu&orderNo=" + orderNo,
+                "商品销售",
+                "商品销售",
+                student.getOrganId(),
+                "goodsSell"
+        );
+
+        studentPaymentOrder.setMerNos((String) payMap.get("routingMerNos"));
+        studentPaymentOrder.setPaymentChannel((String) payMap.get("type"));
+        studentPaymentOrderService.update(studentPaymentOrder);
+        return payMap;
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
     public Map addRepair(StudentRepair repairInfo) throws Exception {
     public Map addRepair(StudentRepair repairInfo) throws Exception {
         studentDao.lockUser(repairInfo.getEmployeeId());
         studentDao.lockUser(repairInfo.getEmployeeId());
         if (repairInfo.getSendType() != null && repairInfo.getSendType().equals(1) &&
         if (repairInfo.getSendType() != null && repairInfo.getSendType().equals(1) &&
@@ -388,6 +497,61 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
 
 
     @Override
     @Override
     @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
     @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+    public void goodsSellorderCallback(StudentPaymentOrder studentPaymentOrder) {
+        Date nowDate = new Date();
+        //更新订单信息
+        studentPaymentOrder.setUpdateTime(nowDate);
+        int updateCount = studentPaymentOrderService.update(studentPaymentOrder);
+        if (updateCount <= 0) {
+            throw new BizException("订单更新失败");
+        }
+
+        Integer userId = studentPaymentOrder.getUserId();
+
+        Map<Integer, String> map = new HashMap<>();
+        map.put(userId, userId.toString());
+
+        if (studentPaymentOrder.getStatus() == DealStatusEnum.SUCCESS) {
+            //插入交易明细
+            BigDecimal amount = studentPaymentOrder.getActualAmount();
+            SysUserCashAccount cashAccount = sysUserCashAccountService.get(userId);
+            //充值
+            SysUserCashAccountDetail rechargeDetail = new SysUserCashAccountDetail();
+            rechargeDetail.setAmount(amount);
+            rechargeDetail.setBalance(cashAccount.getBalance().add(amount));
+            rechargeDetail.setComment("缴费前充值");
+            rechargeDetail.setStatus(DealStatusEnum.SUCCESS);
+            rechargeDetail.setTransNo(studentPaymentOrder.getTransNo());
+            rechargeDetail.setType(PlatformCashAccountDetailTypeEnum.RECHARGE);
+            rechargeDetail.setUserId(userId);
+            rechargeDetail.setChannel(studentPaymentOrder.getPaymentChannel());
+            rechargeDetail.setComAmount(studentPaymentOrder.getComAmount());
+            rechargeDetail.setPerAmount(studentPaymentOrder.getPerAmount());
+            sysUserCashAccountDetailService.insert(rechargeDetail);
+            //缴费
+            SysUserCashAccountDetail paymentDetail = new SysUserCashAccountDetail();
+            paymentDetail.setAmount(amount.negate());
+            paymentDetail.setBalance(cashAccount.getBalance());
+            paymentDetail.setComment("商品销售");
+            paymentDetail.setStatus(DealStatusEnum.SUCCESS);
+            paymentDetail.setTransNo(studentPaymentOrder.getTransNo());
+            paymentDetail.setType(PlatformCashAccountDetailTypeEnum.GOODS_SELL);
+            paymentDetail.setUserId(userId);
+            rechargeDetail.setChannel(studentPaymentOrder.getPaymentChannel());
+            if (studentPaymentOrder.getComAmount() != null) {
+                rechargeDetail.setComAmount(studentPaymentOrder.getComAmount().negate());
+                rechargeDetail.setPerAmount(studentPaymentOrder.getPerAmount().negate());
+            }
+            sysUserCashAccountDetailService.insert(paymentDetail);
+        }else if(studentPaymentOrder.getStatus() == DealStatusEnum.CLOSE || studentPaymentOrder.getStatus() == DealStatusEnum.FAILED){
+            if (studentPaymentOrder.getBalancePaymentAmount() != null && studentPaymentOrder.getBalancePaymentAmount().compareTo(BigDecimal.ZERO) > 0) {
+                sysUserCashAccountService.updateBalance(studentPaymentOrder.getUserId(), studentPaymentOrder.getBalancePaymentAmount(), PlatformCashAccountDetailTypeEnum.REFUNDS, "乐器维修支付失败");
+            }
+        }
+    }
+
+    @Override
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
     public Boolean orderCallback(StudentPaymentOrder studentPaymentOrder) {
     public Boolean orderCallback(StudentPaymentOrder studentPaymentOrder) {
         Date nowDate = new Date();
         Date nowDate = new Date();
         //更新订单信息
         //更新订单信息

+ 1 - 3
mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderMapper.xml

@@ -134,9 +134,6 @@
             <if test="merNos != null">
             <if test="merNos != null">
                 mer_nos_ = #{merNos},
                 mer_nos_ = #{merNos},
             </if>
             </if>
-            <if test="updateTime != null">
-                update_time_ = NOW(),
-            </if>
             <if test="paymentBusinessChannel != null">
             <if test="paymentBusinessChannel != null">
                 payment_business_channel_ = #{paymentBusinessChannel},
                 payment_business_channel_ = #{paymentBusinessChannel},
             </if>
             </if>
@@ -179,6 +176,7 @@
             <if test="version != null">
             <if test="version != null">
                 version_ = version_+1,
                 version_ = version_+1,
             </if>
             </if>
+            update_time_ = NOW()
         </set>
         </set>
         WHERE id_ = #{id} AND version_ = #{version}
         WHERE id_ = #{id} AND version_ = #{version}
     </update>
     </update>

+ 9 - 2
mec-biz/src/main/resources/config/mybatis/SysUserCashAccountDetailMapper.xml

@@ -86,10 +86,17 @@
     <insert id="batchInsert" parameterType="com.ym.mec.biz.dal.entity.SysUserCashAccountDetail" useGeneratedKeys="true"
     <insert id="batchInsert" parameterType="com.ym.mec.biz.dal.entity.SysUserCashAccountDetail" useGeneratedKeys="true"
             keyColumn="id" keyProperty="id">
             keyColumn="id" keyProperty="id">
         INSERT INTO sys_user_cash_account_detail
         INSERT INTO sys_user_cash_account_detail
-        (user_id_,trans_no_,type_,trans_type_,status_,amount_,balance_,description_,comment_,create_time_,update_time_,attribute1_,channel_,platform_account_no_)
+        (user_id_,trans_no_,type_,trans_type_,status_,amount_,balance_,description_,comment_,
+        create_time_,update_time_,attribute1_,channel_,platform_account_no_)
         VALUE
         VALUE
         <foreach collection="sysUserCashAccountDetails" item="sysUserCashAccountDetail" separator=",">
         <foreach collection="sysUserCashAccountDetails" item="sysUserCashAccountDetail" separator=",">
-            (#{sysUserCashAccountDetail.userId},#{sysUserCashAccountDetail.transNo},#{sysUserCashAccountDetail.type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{sysUserCashAccountDetail.transType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{sysUserCashAccountDetail.status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{sysUserCashAccountDetail.amount},#{sysUserCashAccountDetail.balance},#{sysUserCashAccountDetail.description},#{sysUserCashAccountDetail.comment},now(),now(),#{sysUserCashAccountDetail.attribute},#{sysUserCashAccountDetail.channel},#{sysUserCashAccountDetail.platformAccountNo})
+            (#{sysUserCashAccountDetail.userId},#{sysUserCashAccountDetail.transNo},
+            #{sysUserCashAccountDetail.type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
+            #{sysUserCashAccountDetail.transType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
+            #{sysUserCashAccountDetail.status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
+            #{sysUserCashAccountDetail.amount},#{sysUserCashAccountDetail.balance},#{sysUserCashAccountDetail.description},
+            #{sysUserCashAccountDetail.comment},now(),now(),#{sysUserCashAccountDetail.attribute},#{sysUserCashAccountDetail.channel},
+            #{sysUserCashAccountDetail.platformAccountNo})
         </foreach>
         </foreach>
     </insert>
     </insert>
 
 

+ 11 - 0
mec-common/common-core/src/main/java/com/ym/mec/common/service/BaseService.java

@@ -97,6 +97,17 @@ public interface BaseService<PK extends Serializable, T> {
 	 * @date 2020.06.23
 	 * @date 2020.06.23
 	 * @param columnKey: key所对应的列名
 	 * @param columnKey: key所对应的列名
 	 * @param columnValue: value所对应的列名
 	 * @param columnValue: value所对应的列名
+	 * @param ids: key条件
+	 * @return java.util.List<java.util.Map>
+	 */
+	<K extends List, Y, Z> Map<Y,Z> getMap(String tableName, String columnKey, String columnValue, String ids, Class<Y> keyType, Class<Z> valueType);
+
+	/**
+	 * @describe 获取columnKey-columnValue集合
+	 * @author Joburgess
+	 * @date 2020.06.23
+	 * @param columnKey: key所对应的列名
+	 * @param columnValue: value所对应的列名
 	 * @return java.util.List<java.util.Map>
 	 * @return java.util.List<java.util.Map>
 	 */
 	 */
 	<K extends List, Y, Z> Map<Y,Z> getMap(String tableName, String columnKey, String columnValue,Boolean hasDelFlag, Class<Y> keyType, Class<Z> valueType);
 	<K extends List, Y, Z> Map<Y,Z> getMap(String tableName, String columnKey, String columnValue,Boolean hasDelFlag, Class<Y> keyType, Class<Z> valueType);

+ 48 - 0
mec-common/common-core/src/main/java/com/ym/mec/common/service/impl/BaseServiceImpl.java

@@ -165,6 +165,54 @@ public abstract class BaseServiceImpl<PK extends Serializable, T> implements Bas
 		return result;
 		return result;
 	}
 	}
 
 
+	@Override
+	public <K extends List, Y, Z> Map<Y,Z> getMap(String tableName, String columnKey, String columnValue, String ids, Class<Y> keyType, Class<Z> valueType){
+		if(StringUtils.isEmpty(ids)){
+			return Collections.emptyMap();
+		}
+		StringBuffer sql=new StringBuffer();
+		Map<Y,Z> result=new HashMap();
+		try {
+			SqlSession sqlSession = sqlSessionFactory.openSession();
+			Connection connection = sqlSession.getConnection();
+			sql.append("SELECT ").append(columnKey).append(",").append(columnValue).append(" FROM ").append(tableName).append(" WHERE ").append(columnKey).append(" IN (").append(ids).append(")");
+			PreparedStatement ps = connection.prepareStatement(sql.toString());
+			ResultSet resultSet = ps.executeQuery();
+			while (resultSet.next()){
+				Y key;
+				Z value;
+				if(keyType.isAssignableFrom(BigDecimal.class)){
+					key = (Y) BigDecimal.class.getDeclaredConstructor(String.class).newInstance(resultSet.getString(1));
+				}else if(keyType.isAssignableFrom(String.class)){
+					key = (Y) resultSet.getString(1);
+				}else{
+					key = (Y) keyType.getMethod("valueOf", String.class).invoke(null,resultSet.getString(1));
+				}
+				if(valueType.isAssignableFrom(BigDecimal.class)){
+					value = (Z) BigDecimal.class.getDeclaredConstructor(String.class).newInstance(resultSet.getString(2));
+				}else if(valueType.isAssignableFrom(String.class)){
+					value = (Z) resultSet.getString(2);
+				}else{
+					value = (Z) valueType.getMethod("valueOf", String.class).invoke(null,resultSet.getString(2));
+				}
+				result.put(key, value);
+			}
+			if(resultSet!=null){
+				resultSet.close();
+			}
+			if(ps!=null){
+				ps.close();
+			}
+			if(sqlSession!=null){
+				sqlSession.close();
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+
+		return result;
+	}
+
 
 
 	@Override
 	@Override
 	public <K extends List, Y, Z> Map<Y,Z> getMap(String tableName, String columnKey, String columnValue,Boolean hasDelFlag, Class<Y> keyType, Class<Z> valueType){
 	public <K extends List, Y, Z> Map<Y,Z> getMap(String tableName, String columnKey, String columnValue,Boolean hasDelFlag, Class<Y> keyType, Class<Z> valueType){

+ 31 - 9
mec-student/src/main/java/com/ym/mec/student/controller/RepairController.java

@@ -3,26 +3,29 @@ package com.ym.mec.student.controller;
 
 
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.auth.api.entity.SysUser;
-import com.ym.mec.biz.dal.dao.EmployeeDao;
-import com.ym.mec.biz.dal.entity.Employee;
+import com.ym.mec.biz.dal.dto.GoodsSellDto;
+import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
 import com.ym.mec.biz.dal.entity.StudentRepair;
 import com.ym.mec.biz.dal.entity.StudentRepair;
-import com.ym.mec.biz.dal.page.GoodsQueryInfo;
+import com.ym.mec.biz.dal.enums.DealStatusEnum;
+import com.ym.mec.biz.dal.enums.GroupType;
+import com.ym.mec.biz.dal.enums.OrderTypeEnum;
 import com.ym.mec.biz.dal.page.RepairStudentQueryInfo;
 import com.ym.mec.biz.dal.page.RepairStudentQueryInfo;
-import com.ym.mec.biz.service.GoodsService;
+import com.ym.mec.biz.service.StudentPaymentOrderService;
 import com.ym.mec.biz.service.StudentRepairService;
 import com.ym.mec.biz.service.StudentRepairService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.entity.HttpResponseResult;
+import com.ym.mec.common.exception.BizException;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.HttpStatus;
-import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.bind.annotation.RestController;
 
 
-import java.util.Objects;
+import java.util.List;
+import java.util.Map;
 
 
 @RequestMapping("repair")
 @RequestMapping("repair")
 @Api(tags = "学生维修服务")
 @Api(tags = "学生维修服务")
@@ -31,12 +34,31 @@ public class RepairController extends BaseController {
 
 
     @Autowired
     @Autowired
     private SysUserFeignService sysUserFeignService;
     private SysUserFeignService sysUserFeignService;
-
     @Autowired
     @Autowired
     private StudentRepairService studentRepairService;
     private StudentRepairService studentRepairService;
-
     @Autowired
     @Autowired
-    private GoodsService goodsService;
+    private StudentPaymentOrderService studentPaymentOrderService;
+
+    @ApiOperation("添加商品销售订单")
+    @PostMapping(value = "/addGoodsSellOrder")
+    public HttpResponseResult addGoodsSellOrder(GoodsSellDto goodsSellDto) throws Exception {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            throw new BizException("请登录");
+        }
+        if (goodsSellDto.getIsRepeatPay() == false) {
+            List<StudentPaymentOrder> list = studentPaymentOrderService.queryByCondition(GroupType.GOODS_SELL, null, sysUser.getId(), DealStatusEnum.ING,
+                    OrderTypeEnum.RENEW);
+            if (list.size() > 0) {
+                return failed(HttpStatus.CONTINUE, "您有待支付的订单");
+            }
+        }
+        Map map = studentRepairService.addGoodsSellOrder(goodsSellDto);
+        if(map.containsKey("tradeState")){
+            return failed(HttpStatus.CREATED, "恭喜您,购买成功!");
+        }
+        return succeed(map);
+    }
 
 
     @ApiOperation("获取维修记录")
     @ApiOperation("获取维修记录")
     @GetMapping(value = "/getStudentRepairList")
     @GetMapping(value = "/getStudentRepairList")

+ 1 - 0
mec-web/src/main/java/com/ym/mec/web/controller/education/EduRepairController.java

@@ -5,6 +5,7 @@ import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.EmployeeDao;
 import com.ym.mec.biz.dal.dao.EmployeeDao;
 import com.ym.mec.biz.dal.dto.BasicUserDto;
 import com.ym.mec.biz.dal.dto.BasicUserDto;
+import com.ym.mec.biz.dal.dto.GoodsSellDto;
 import com.ym.mec.biz.dal.entity.Employee;
 import com.ym.mec.biz.dal.entity.Employee;
 import com.ym.mec.biz.dal.entity.StudentRepair;
 import com.ym.mec.biz.dal.entity.StudentRepair;
 import com.ym.mec.biz.dal.page.GoodsCategoryQueryInfo;
 import com.ym.mec.biz.dal.page.GoodsCategoryQueryInfo;