zouxuan 4 年之前
父节点
当前提交
7d87c3e722

+ 8 - 8
codegen/src/main/resources/generateConfigration.xml

@@ -2,16 +2,16 @@
 <GenerateConfiguration>
 	<dbConfiguration>
 		<driverClass>com.mysql.jdbc.Driver</driverClass>
-		<url>jdbc:mysql://47.114.176.40:3306/edu_saas</url>
-		<username>edu_saas</username>
+		<url>jdbc:mysql://47.114.1.200:3306/mec_dev</url>
+		<username>mec_dev</username>
 		<password>dayaDataOnline@2019</password>
-		<catalog>edu_saas</catalog>
-		<schema>edu_saas</schema>
+		<catalog>mec_dev</catalog>
+		<schema>mec_dev</schema>
 	</dbConfiguration>
-	<srcBase>e:/javabean</srcBase>
-	<pojoPackageName>com.keao.edu.datasource.dal.entity</pojoPackageName>
-	<daoPackageName>com.keao.edu.datasource.dal.dao</daoPackageName>
-	<servicePackageName>com.keao.edu.datasource.service</servicePackageName>
+	<srcBase>d:/javabean</srcBase>
+	<pojoPackageName>com.ym.mec.biz.dal.entity</pojoPackageName>
+	<daoPackageName>com.ym.mec.biz.dal.dao</daoPackageName>
+	<servicePackageName>com.ym.mec.biz.service</servicePackageName>
 	<sqlmapPackageName>resources</sqlmapPackageName>
 	<sqlmapConfigPackageName>resources/config</sqlmapConfigPackageName>
 </GenerateConfiguration>

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentGoodsSellDao.java

@@ -0,0 +1,10 @@
+package com.ym.mec.biz.dal.dao;
+
+
+import com.ym.mec.biz.dal.entity.StudentGoodsSell;
+import com.ym.mec.common.dal.BaseDAO;
+
+public interface StudentGoodsSellDao extends BaseDAO<Integer, StudentGoodsSell> {
+
+	
+}

+ 10 - 21
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/GoodsSellDto.java

@@ -3,36 +3,25 @@ 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)
+	private Integer goodsNum;
 
-	@ApiModelProperty(value = "商品列表", required = false)
-	String goodsId;
+	@ApiModelProperty(value = "商品编号", required = false)
+	private Integer 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 Integer getGoodsNum() {
+		return goodsNum;
 	}
 
-	public void setIsUseBalancePayment(Boolean useBalancePayment) {
-		isUseBalancePayment = useBalancePayment;
+	public void setGoodsNum(Integer goodsNum) {
+		this.goodsNum = goodsNum;
 	}
 
-	public String getGoodsId() {
+	public Integer getGoodsId() {
 		return goodsId;
 	}
 
-	public void setGoodsId(String goodsId) {
+	public void setGoodsId(Integer goodsId) {
 		this.goodsId = goodsId;
 	}
 }

+ 160 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentGoodsSell.java

@@ -0,0 +1,160 @@
+package com.ym.mec.biz.dal.entity;
+
+import com.ym.mec.biz.dal.dto.GoodsSellDto;
+import io.swagger.annotations.ApiModelProperty;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 对应数据库表(student_goods_sell):
+ */
+public class StudentGoodsSell {
+
+	private Integer id;
+	
+	@ApiModelProperty(value = "用户编号",required = true)
+	private Integer userId;
+	
+	@ApiModelProperty(value = "教师编号",required = true)
+	private Integer teacherId;
+	
+	@ApiModelProperty(value = "商品列表",required = true)
+	private String goodsJson;
+
+	@ApiModelProperty(value = "订单编号",required = true)
+	private String orderNo;
+	
+	@ApiModelProperty(value = "总金额",required = true)
+	private java.math.BigDecimal totalAmount;
+	
+	@ApiModelProperty(value = "减免费用",required = true)
+	private java.math.BigDecimal marketAmount;
+
+	private Date createTime;
+
+	private Date updateTime;
+
+	@ApiModelProperty(value = "是否使用余额",required = true)
+	private Boolean isUseBalancePayment;
+
+	@ApiModelProperty(value = "是否重复支付",required = true)
+	private boolean isRepeatPay;
+
+	@ApiModelProperty(value = "商品列表",required = true)
+	private List<GoodsSellDto> goodsSellDtos;
+
+	@ApiModelProperty(value = "支付类型",required = true)
+	private Integer type;
+
+	public Integer getType() {
+		return type;
+	}
+
+	public void setType(Integer type) {
+		this.type = type;
+	}
+
+	public List<GoodsSellDto> getGoodsSellDtos() {
+		return goodsSellDtos;
+	}
+
+	public void setGoodsSellDtos(List<GoodsSellDto> goodsSellDtos) {
+		this.goodsSellDtos = goodsSellDtos;
+	}
+
+	public String getOrderNo() {
+		return orderNo;
+	}
+
+	public void setOrderNo(String orderNo) {
+		this.orderNo = orderNo;
+	}
+
+	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 Date getCreateTime() {
+		return createTime;
+	}
+
+	public void setCreateTime(Date createTime) {
+		this.createTime = createTime;
+	}
+
+	public Date getUpdateTime() {
+		return updateTime;
+	}
+
+	public void setUpdateTime(Date updateTime) {
+		this.updateTime = updateTime;
+	}
+
+	public void setId(Integer id){
+		this.id = id;
+	}
+	
+	public Integer getId(){
+		return this.id;
+	}
+			
+	public void setUserId(Integer userId){
+		this.userId = userId;
+	}
+	
+	public Integer getUserId(){
+		return this.userId;
+	}
+			
+	public void setTeacherId(Integer teacherId){
+		this.teacherId = teacherId;
+	}
+	
+	public Integer getTeacherId(){
+		return this.teacherId;
+	}
+			
+	public void setGoodsJson(String goodsJson){
+		this.goodsJson = goodsJson;
+	}
+	
+	public String getGoodsJson(){
+		return this.goodsJson;
+	}
+			
+	public void setTotalAmount(java.math.BigDecimal totalAmount){
+		this.totalAmount = totalAmount;
+	}
+	
+	public java.math.BigDecimal getTotalAmount(){
+		return this.totalAmount;
+	}
+			
+	public void setMarketAmount(java.math.BigDecimal marketAmount){
+		this.marketAmount = marketAmount;
+	}
+	
+	public java.math.BigDecimal getMarketAmount(){
+		return this.marketAmount;
+	}
+			
+	@Override
+	public String toString() {
+		return ToStringBuilder.reflectionToString(this);
+	}
+
+}

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

@@ -0,0 +1,9 @@
+package com.ym.mec.biz.service;
+
+
+import com.ym.mec.biz.dal.entity.StudentGoodsSell;
+import com.ym.mec.common.service.BaseService;
+
+public interface StudentGoodsSellService extends BaseService<Integer, StudentGoodsSell> {
+
+}

+ 3 - 6
mec-biz/src/main/java/com/ym/mec/biz/service/StudentRepairService.java

@@ -1,16 +1,13 @@
 package com.ym.mec.biz.service;
 
 import com.ym.mec.biz.dal.dto.BasicUserDto;
-import com.ym.mec.biz.dal.dto.GoodsSellDto;
+import com.ym.mec.biz.dal.entity.StudentGoodsSell;
 import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
 import com.ym.mec.biz.dal.entity.StudentRepair;
 import com.ym.mec.biz.dal.page.RepairStudentQueryInfo;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.BaseService;
-import org.springframework.stereotype.Service;
 
-import java.math.BigDecimal;
-import java.util.Date;
 import java.util.Map;
 
 public interface StudentRepairService extends BaseService<Integer, StudentRepair> {
@@ -75,10 +72,10 @@ public interface StudentRepairService extends BaseService<Integer, StudentRepair
      * @author zouxuan
      * @date 2020/9/16
      * @time 13:47
-     * @param goodsSellDto:
+     * @param studentGoodsSell:
      * @return java.util.Map
      */
-    Map addGoodsSellOrder(GoodsSellDto goodsSellDto) throws Exception;
+    Map addGoodsSellOrder(StudentGoodsSell studentGoodsSell) throws Exception;
 
     /**
      * @describe 商品销售订单回调

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

@@ -0,0 +1,23 @@
+package com.ym.mec.biz.service.impl;
+
+
+import com.ym.mec.biz.dal.dao.StudentGoodsSellDao;
+import com.ym.mec.biz.dal.entity.StudentGoodsSell;
+import com.ym.mec.biz.service.StudentGoodsSellService;
+import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.service.impl.BaseServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class StudentGoodsSellServiceImpl extends BaseServiceImpl<Integer, StudentGoodsSell> implements StudentGoodsSellService {
+	
+	@Autowired
+	private StudentGoodsSellDao studentGoodsSellDao;
+
+	@Override
+	public BaseDAO<Integer, StudentGoodsSell> getDAO() {
+		return studentGoodsSellDao;
+	}
+	
+}

+ 29 - 12
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRepairServiceImpl.java

@@ -5,8 +5,8 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
-import com.ym.mec.biz.dal.dao.SellOrderDao;
 import com.ym.mec.biz.dal.dao.StudentDao;
+import com.ym.mec.biz.dal.dao.StudentGoodsSellDao;
 import com.ym.mec.biz.dal.dao.StudentRepairDao;
 import com.ym.mec.biz.dal.dao.SysConfigDao;
 import com.ym.mec.biz.dal.dto.BasicUserDto;
@@ -67,7 +67,7 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
     @Autowired
     private SellOrderService sellOrderService;
     @Autowired
-    private SellOrderDao sellOrderDao;
+    private StudentGoodsSellDao studentGoodsSellDao;
 
     @Override
     public BaseDAO<Integer, StudentRepair> getDAO() {
@@ -103,11 +103,11 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public Map addGoodsSellOrder(GoodsSellDto goodsSellDto) throws Exception {
+    public Map addGoodsSellOrder(StudentGoodsSell studentGoodsSell) throws Exception {
         SysUser sysUser = sysUserFeignService.queryUserInfo();
         Integer studentId = sysUser.getId();
-        String goodsId = goodsSellDto.getGoodsId();
-        if (StringUtils.isEmpty(goodsId)) {
+        List<GoodsSellDto> goodsSellDtos = studentGoodsSell.getGoodsSellDtos();
+        if(goodsSellDtos == null || goodsSellDtos.size() == 0){
             throw new BizException("请选择需要购买的商品");
         }
         if (studentId == null) {
@@ -116,14 +116,31 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
         studentDao.lockUser(studentId);
         SysUser student = sysUserFeignService.queryUserById(studentId);
         String orderNo = idGeneratorService.generatorId("payment") + "";
+        studentGoodsSell.setOrderNo(orderNo);
 
-        String[] goodsIds = goodsId.split(",");
-        Map<String, BigDecimal> map = getMap("goods", "id_", "group_purchase_price_", goodsId, String.class, BigDecimal.class);
+        List<Integer> goodsIds = goodsSellDtos.stream().map(e -> e.getGoodsId()).collect(Collectors.toList());
+//        Map<Integer, List<GoodsSellDto>> goodsMap = goodsSellDtos.stream().collect(Collectors.groupingBy(GoodsSellDto::getGoodsId));
+//        String[] goodsIds = goodsId.split(",");
+        Map<Integer, BigDecimal> map = getMap("goods", "id_", "market_price_", goodsIds, Integer.class, BigDecimal.class);
         BigDecimal amount = BigDecimal.ZERO;
-        for (String id : goodsIds) {
+        for (Integer id : goodsIds) {
             amount.add(map.get(id));
         }
-        List<Goods> goods = goodsService.findGoodsByIds(goodsId);
+        studentGoodsSell.setGoodsJson(JSONObject.toJSONString(goodsSellDtos));
+        studentGoodsSell.setTotalAmount(amount);
+        if(studentGoodsSell.getId() == null){
+            studentGoodsSellDao.insert(studentGoodsSell);
+        }else {
+            studentGoodsSellDao.update(studentGoodsSell);
+        }
+
+        if (studentGoodsSell.getType() == 1) {
+            Map<String, Object> repairInfoMap = new HashMap<>();
+            MapUtil.populateMap(repairInfoMap, studentGoodsSell);
+            return repairInfoMap;
+        }
+
+        List<Goods> goods = goodsService.findGoodsByIds(StringUtils.join(goodsIds,","));
 
         StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder();
         studentPaymentOrder.setUserId(studentId);
@@ -139,7 +156,7 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
 
         Map<Integer, List<Goods>> collect = goods.stream().collect(Collectors.groupingBy(Goods::getId));
         List<StudentPaymentOrderDetail> studentPaymentOrderDetailList = new ArrayList<>();
-        for (String id : goodsIds) {
+        for (Integer id : goodsIds) {
             Goods e = collect.get(id).get(0);
             StudentPaymentOrderDetail studentPaymentOrderDetail = new StudentPaymentOrderDetail();
             studentPaymentOrderDetail.setRemitFee(BigDecimal.ZERO);
@@ -153,7 +170,7 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
             }
             studentPaymentOrderDetail.setType(type);
             studentPaymentOrderDetail.setPrice(e.getGroupPurchasePrice());
-            studentPaymentOrderDetail.setGoodsIdList(id);
+            studentPaymentOrderDetail.setGoodsIdList(id.toString());
             studentPaymentOrderDetail.setPaymentOrderId(studentPaymentOrder.getId());
             studentPaymentOrderDetail.setKitGroupPurchaseType(KitGroupPurchaseTypeEnum.GROUP);
             studentPaymentOrderDetailList.add(studentPaymentOrderDetail);
@@ -162,7 +179,7 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
 
         studentPaymentOrder.setVersion(0);
         BigDecimal balance = BigDecimal.ZERO;
-        if (goodsSellDto.getIsUseBalancePayment() && amount.compareTo(BigDecimal.ZERO) > 0) {
+        if (studentGoodsSell.getIsUseBalancePayment() && amount.compareTo(BigDecimal.ZERO) > 0) {
             SysUserCashAccount userCashAccount = sysUserCashAccountService.getLocked(studentId);
             if (userCashAccount == null) {
                 throw new BizException("用户账户找不到");

+ 76 - 0
mec-biz/src/main/resources/config/mybatis/StudentGoodsSellMapper.xml

@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<!--
+这个文件是自动生成的。
+不要修改此文件。所有改动将在下次重新自动生成时丢失。
+-->
+<mapper namespace="com.ym.mec.biz.dal.dao.StudentGoodsSellDao">
+	
+	<resultMap type="com.ym.mec.biz.dal.entity.StudentGoodsSell" id="StudentGoodsSell">
+		<result column="id_" property="id" />
+		<result column="user_id_" property="userId" />
+		<result column="teacher_id_" property="teacherId" />
+		<result column="goods_json_" property="goodsJson" />
+		<result column="total_amount_" property="totalAmount" />
+		<result column="market_amount_" property="marketAmount" />
+		<result column="order_no_" property="orderNo" />
+		<result column="create_time_" property="createTime" />
+		<result column="update_time_" property="updateTime" />
+	</resultMap>
+	
+	<!-- 根据主键查询一条记录 -->
+	<select id="get" resultMap="StudentGoodsSell" >
+		SELECT * FROM student_goods_sell WHERE id_ = #{id} 
+	</select>
+	
+	<!-- 全查询 -->
+	<select id="findAll" resultMap="StudentGoodsSell">
+		SELECT * FROM student_goods_sell ORDER BY id_
+	</select>
+	
+	<!-- 向数据库增加一条记录 -->
+	<insert id="insert" parameterType="com.ym.mec.biz.dal.entity.StudentGoodsSell" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
+		INSERT INTO student_goods_sell (id_,user_id_,teacher_id_,goods_json_,total_amount_,market_amount_,create_time_,update_time_,order_no_)
+		VALUES(#{id},#{userId},#{teacherId},#{goodsJson},#{totalAmount},#{marketAmount},NOW(),NOW(),#{orderNo})
+	</insert>
+	
+	<!-- 根据主键查询一条记录 -->
+	<update id="update" parameterType="com.ym.mec.biz.dal.entity.StudentGoodsSell">
+		UPDATE student_goods_sell <set>
+		<if test="orderNo != null">
+			order_no_ = #{orderNo},
+		</if>
+		<if test="userId != null">
+			user_id_ = #{userId},
+		</if>
+		<if test="totalAmount != null">
+			total_amount_ = #{totalAmount},
+		</if>
+		<if test="marketAmount != null">
+			market_amount_ = #{marketAmount},
+		</if>
+		<if test="teacherId != null">
+			teacher_id_ = #{teacherId},
+		</if>
+		<if test="goodsJson != null">
+			goods_json_ = #{goodsJson},
+		</if>
+		update_time_ = NOW()
+		</set> WHERE id_ = #{id}
+	</update>
+	
+	<!-- 根据主键删除一条记录 -->
+	<delete id="delete" >
+		DELETE FROM student_goods_sell WHERE id_ = #{id} 
+	</delete>
+	
+	<!-- 分页查询 -->
+	<select id="queryPage" resultMap="StudentGoodsSell" parameterType="map">
+		SELECT * FROM student_goods_sell ORDER BY id_ <include refid="global.limit"/>
+	</select>
+	
+	<!-- 查询当前表的总记录数 -->
+	<select id="queryCount" resultType="int">
+		SELECT COUNT(*) FROM student_goods_sell
+	</select>
+</mapper>

+ 6 - 8
mec-student/src/main/java/com/ym/mec/student/controller/RepairController.java

@@ -3,7 +3,7 @@ package com.ym.mec.student.controller;
 
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
-import com.ym.mec.biz.dal.dto.GoodsSellDto;
+import com.ym.mec.biz.dal.entity.StudentGoodsSell;
 import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
 import com.ym.mec.biz.dal.entity.StudentRepair;
 import com.ym.mec.biz.dal.enums.DealStatusEnum;
@@ -19,10 +19,7 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
 import java.util.Map;
@@ -41,19 +38,20 @@ public class RepairController extends BaseController {
 
     @ApiOperation("添加商品销售订单")
     @PostMapping(value = "/addGoodsSellOrder")
-    public HttpResponseResult addGoodsSellOrder(GoodsSellDto goodsSellDto) throws Exception {
+    public HttpResponseResult addGoodsSellOrder(@RequestBody StudentGoodsSell studentGoodsSell) throws Exception {
         SysUser sysUser = sysUserFeignService.queryUserInfo();
         if (sysUser == null) {
             throw new BizException("请登录");
         }
-        if (goodsSellDto.getIsRepeatPay() == false) {
+        if (studentGoodsSell.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);
+        studentGoodsSell.setUserId(sysUser.getId());
+        Map map = studentRepairService.addGoodsSellOrder(studentGoodsSell);
         if(map.containsKey("tradeState")){
             return failed(HttpStatus.CREATED, "恭喜您,购买成功!");
         }

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

@@ -5,7 +5,6 @@ import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.EmployeeDao;
 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.StudentRepair;
 import com.ym.mec.biz.dal.page.GoodsCategoryQueryInfo;