zouxuan 4 年之前
父节点
当前提交
2f51d2853a

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

@@ -46,4 +46,26 @@ public interface StudentGoodsSellDao extends BaseDAO<Integer, StudentGoodsSell>
     StudentGoodsSell findByOrderNo(@Param("orderNo") String orderNo);
 
     StudentGoodsSellDto getStudentGoodsSellDto(String orderNo);
+
+    /**
+     * @describe 获取到期未确认的订单
+     * @apiNote 时光荏苒,认真工作的时间总是过得很快,而我、享受这一刻!
+     * @author zouxuan
+     * @date 2020/10/12
+     * @time 10:09
+     * @param autoAffirmReceiveTime:
+     * @return java.util.List<java.lang.String>
+     */
+    String queryNoAffirmOrderNo(String autoAffirmReceiveTime);
+
+    /**
+     * @describe 自动确认收货
+     * @apiNote 时光荏苒,认真工作的时间总是过得很快,而我、享受这一刻!
+     * @author zouxuan
+     * @date 2020/10/12
+     * @time 10:15
+     * @param orderNo:
+     * @return void
+     */
+    void autoAffirmReceive(@Param("orderNo") String orderNo, @Param("status") String status);
 }

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/TeacherDao.java

@@ -474,4 +474,6 @@ public interface TeacherDao extends BaseDAO<Integer, Teacher> {
     int countStudent(Map<String, Object> params);
     
     List<TeacherDefaultSalaryDto> queryTeacherDefaultSalary(@Param("organIdList") String organIdList);
+
+    BasicUserDto findUserByPhone(String phone);
 }

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

@@ -172,6 +172,17 @@ public class SellOrder {
     @ApiModelProperty(value="更新时间")
     private Date updateTime;
 
+    @ApiModelProperty(value = "收货状态,NO_RECEIVE 未确认,MANUAL_RECEIVE 手动确认,AUTO_RECEIVE 自动确认",required = true)
+    private String receiveStatus;
+
+    public String getReceiveStatus() {
+        return receiveStatus;
+    }
+
+    public void setReceiveStatus(String receiveStatus) {
+        this.receiveStatus = receiveStatus;
+    }
+
     public Integer getId() {
         return id;
     }

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentPaymentOrder.java

@@ -107,6 +107,9 @@ public class StudentPaymentOrder {
 	//收款账户
 	private String merNos;
 
+	@ApiModelProperty(value = "收货状态,NO_RECEIVE 未确认,MANUAL_RECEIVE 手动确认,AUTO_RECEIVE 自动确认",required = true)
+	private String receiveStatus;
+
 	private PaymentChannelTypeEnum paymentChannelType;
 	
 	private SysUser user = new SysUser();
@@ -117,6 +120,14 @@ public class StudentPaymentOrder {
 	//课程优惠金额
 	private BigDecimal courseRemitFee;
 
+	public String getReceiveStatus() {
+		return receiveStatus;
+	}
+
+	public void setReceiveStatus(String receiveStatus) {
+		this.receiveStatus = receiveStatus;
+	}
+
 	public void setId(Long id){
 		this.id = id;
 	}

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

@@ -19,4 +19,15 @@ public interface StudentGoodsSellService extends BaseService<Integer, StudentGoo
      * @return java.lang.Object
      */
     PageInfo<StudentGoodsSellDto> queryStudentGoodsOrders(GoodsSellQueryInfo queryInfo);
+
+    /**
+     * @describe 确认收货
+     * @apiNote 时光荏苒,认真工作的时间总是过得很快,而我、享受这一刻!
+     * @author zouxuan
+     * @date 2020/10/10
+     * @time 17:53
+     * @param orderNo:
+     * @return void
+     */
+    void affirmReceive(String orderNo);
 }

+ 6 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/GoodsServiceImpl.java

@@ -6,6 +6,8 @@ import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.GoodsDao;
 import com.ym.mec.biz.dal.dao.GoodsProcurementDao;
 import com.ym.mec.biz.dal.dao.SysConfigDao;
+import com.ym.mec.biz.dal.dao.TeacherDao;
+import com.ym.mec.biz.dal.dto.BasicUserDto;
 import com.ym.mec.biz.dal.entity.Goods;
 import com.ym.mec.biz.dal.entity.GoodsProcurement;
 import com.ym.mec.biz.dal.enums.GoodsType;
@@ -56,7 +58,7 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 	@Autowired
 	private SysMessageService sysMessageService;
 	@Autowired
-	private SysUserFeignService sysUserFeignService;
+	private TeacherDao teacherDao;
 
 	@Override
 	public BaseDAO<Integer, Goods> getDAO() {
@@ -207,12 +209,12 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 		if(StringUtils.isEmpty(repertoryWarnPhone)){
 			return;
 		}
-		SysUser sysUser = sysUserFeignService.queryUserByMobile(repertoryWarnPhone);
-		if(sysUser == null || sysUser.getId() == null){
+		BasicUserDto sysUser = teacherDao.findUserByPhone(repertoryWarnPhone);
+		if(sysUser == null || sysUser.getUserId() == null){
 			throw new BizException("库存预警手机号不存在");
 		}
 		Map<Integer, String> receivers = new HashMap<>(1);
-		receivers.put(sysUser.getId(), repertoryWarnPhone);
+		receivers.put(sysUser.getUserId(), repertoryWarnPhone);
 		//内部库存预警
 		String innerRepertoryWarnNum = sysConfigDao.findConfigValue("inner_repertory_warn_num");
 		if(StringUtils.isNotEmpty(innerRepertoryWarnNum)){

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

@@ -2,6 +2,7 @@ package com.ym.mec.biz.service.impl;
 
 
 import com.ym.mec.biz.dal.dao.StudentGoodsSellDao;
+import com.ym.mec.biz.dal.dao.SysConfigDao;
 import com.ym.mec.biz.dal.dto.StudentGoodsSellDto;
 import com.ym.mec.biz.dal.entity.StudentGoodsSell;
 import com.ym.mec.biz.dal.page.GoodsSellQueryInfo;
@@ -11,8 +12,10 @@ import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.page.QueryInfo;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.util.collection.MapUtil;
+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.util.ArrayList;
 import java.util.HashMap;
@@ -24,6 +27,8 @@ public class StudentGoodsSellServiceImpl extends BaseServiceImpl<Integer, Studen
 	
 	@Autowired
 	private StudentGoodsSellDao studentGoodsSellDao;
+	@Autowired
+	private SysConfigDao sysConfigDao;
 
 	@Override
 	public BaseDAO<Integer, StudentGoodsSell> getDAO() {
@@ -49,4 +54,18 @@ public class StudentGoodsSellServiceImpl extends BaseServiceImpl<Integer, Studen
 		pageInfo.setRows(dataList);
 		return pageInfo;
 	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void affirmReceive(String orderNo) {
+		//如果订单编号为空,那么自动确认
+		if(StringUtils.isEmpty(orderNo)){
+			String autoAffirmReceiveTime = sysConfigDao.findConfigValue("auto_affirm_receive_time");
+			//获取到期的订单编号
+			orderNo = studentGoodsSellDao.queryNoAffirmOrderNo(autoAffirmReceiveTime);
+		}
+		if(StringUtils.isNotEmpty(orderNo)){
+			studentGoodsSellDao.autoAffirmReceive(orderNo,"AUTO_RECEIVE");
+		}
+	}
 }

+ 7 - 1
mec-biz/src/main/resources/config/mybatis/SellOrderMapper.xml

@@ -32,6 +32,7 @@
         <result column="sell_time_" property="sellTime"/>
         <result column="create_ime_" property="createIme"/>
         <result column="update_time_" property="updateTime"/>
+        <result column="receive_status_" property="receiveStatus"/>
     </resultMap>
     <sql id="Base_Column_List">
         <!--@mbg.generated-->
@@ -159,12 +160,13 @@
 
     <!-- 分页查询 -->
     <select id="queryPage" resultMap="SellOrder" parameterType="map">
-        SELECT so.*,su.username_ user_name_,su.phone_,o.name_ organ_name_,co.name_ school_name_,t.real_name_ eduTeacher
+        SELECT so.*,su.username_ user_name_,su.phone_,o.name_ organ_name_,co.name_ school_name_,t.real_name_ eduTeacher,spo.receive_status_
         FROM sell_order so
         LEFT JOIN sys_user su ON so.user_id_ = su.id_
         LEFT JOIN organization o ON o.id_ = so.organ_id_
         LEFT JOIN cooperation_organ co ON co.id_= so.cooperation_organ_id_
         LEFT JOIN sys_user t ON t.id_ = so.edu_teacher_id_
+        LEFT JOIN student_payment_order spo ON so.order_id_ = spo.id_
         <include refid="queryPageSql"/>
         ORDER BY so.create_ime_ DESC
         <include refid="global.limit"/>
@@ -173,6 +175,7 @@
     <!-- 查询当前表的总记录数 -->
     <select id="queryCount" resultType="int">
         SELECT COUNT(*) FROM sell_order so
+        LEFT JOIN student_payment_order spo ON so.order_id_ = spo.id_
         <include refid="queryPageSql"/>
     </select>
 
@@ -193,6 +196,9 @@
             <if test="type != null">
                 AND so.type_ = #{type}
             </if>
+            <if test="receiveStatus != null and receiveStatus != ''">
+                AND spo.receive_status_ = #{receiveStatus}
+            </if>
             <if test="startTime != null">
                 AND so.sell_time_ >= #{startTime}
             </if>

+ 12 - 1
mec-biz/src/main/resources/config/mybatis/StudentGoodsSellMapper.xml

@@ -75,7 +75,10 @@
 		update_time_ = NOW()
 		</set> WHERE id_ = #{id}
 	</update>
-	
+	<update id="autoAffirmReceive">
+		UPDATE student_payment_order SET receive_status_ = #{status},update_time_ = NOW() WHERE FIND_IN_SET(order_no_,#{orderNo})
+	</update>
+
 	<!-- 根据主键删除一条记录 -->
 	<delete id="delete" >
 		DELETE FROM student_goods_sell WHERE id_ = #{id} 
@@ -114,6 +117,9 @@
 			<if test="status != null">
 				AND spo.status_ = #{status}
 			</if>
+			<if test="receiveStatus != null and receiveStatus != ''">
+				AND spo.receive_status_ = #{receiveStatus}
+			</if>
 			<if test="search != null and search != ''">
 				AND (su.username_ LIKE CONCAT('%',#{search},'%') OR su.phone_ LIKE CONCAT('%',#{search},'%'))
 			</if>
@@ -136,4 +142,9 @@
 		LEFT JOIN student_goods_sell sgs ON spo.order_no_ = sgs.order_no_
 		WHERE spo.order_no_ = #{orderNo} LIMIT 1
 	</select>
+    <select id="queryNoAffirmOrderNo" resultType="java.lang.String">
+		SELECT GROUP_CONCAT(DISTINCT so.order_no_) FROM sell_order so
+		LEFT JOIN student_payment_order spo ON spo.order_no_ = so.order_no_
+		WHERE spo.status_ = 'SUCCESS' AND TIMESTAMPDIFF(HOUR,spo.pay_time_,NOW()) >= #{autoAffirmReceiveTime}
+	</select>
 </mapper>

+ 6 - 2
mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderMapper.xml

@@ -33,6 +33,7 @@
         <result column="class_group_id_" property="classGroupId"/>
         <result column="pay_time_" property="payTime"/>
         <result column="version_" property="version"/>
+        <result column="receive_status_" property="receiveStatus"/>
     </resultMap>
 
     <resultMap type="com.ym.mec.biz.dal.entity.StudentPaymentOrder" extends="StudentPaymentOrder"
@@ -88,7 +89,7 @@
          per_amount_,
          balance_payment_amount_, remit_fee_, course_remit_fee_, trans_no_,
          status_, memo_, create_time_, update_time_, payment_channel_, payment_business_channel_,
-         payment_account_no_, mer_nos_, order_no_, music_group_id_, class_group_id_, pay_time_)
+         payment_account_no_, mer_nos_, order_no_, music_group_id_, class_group_id_, pay_time_,receive_status_)
         VALUES (#{id}, #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
                 #{userId}, #{organId}, #{routingOrganId},
                 #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
@@ -97,13 +98,16 @@
                 #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}, #{memo}, now(), now(),
                 #{paymentChannel}, #{paymentBusinessChannel}, #{paymentAccountNo}, #{merNos}, #{orderNo},
                 #{musicGroupId},
-                #{classGroupId}, #{payTime})
+                #{classGroupId}, #{payTime},#{receiveStatus})
     </insert>
 
     <!-- 根据主键查询一条记录 -->
     <update id="update" parameterType="com.ym.mec.biz.dal.entity.StudentPaymentOrder">
         UPDATE student_payment_order
         <set>
+            <if test="receiveStatus != null and receiveStatus != ''">
+                receive_status_ = #{receiveStatus},
+            </if>
             <if test="status != null">
                 status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
             </if>

+ 5 - 0
mec-biz/src/main/resources/config/mybatis/TeacherMapper.xml

@@ -1188,4 +1188,9 @@
 		</where>
 		GROUP BY t.`id_` 
     </select>
+    <select id="findUserByPhone" resultMap="com.ym.mec.biz.dal.dao.MusicGroupDao.BasicUserDto">
+        SELECT username_,id_ user_id_,avatar_ head_url_,
+        gender_,user_type_
+        FROM sys_user WHERE phone_ = #{phone}
+    </select>
 </mapper>

+ 4 - 0
mec-client-api/src/main/java/com/ym/mec/task/TaskRemoteService.java

@@ -140,4 +140,8 @@ public interface TaskRemoteService {
 	//商品库存预警
 	@GetMapping("task/repertoryWarn")
     void goodsRepertoryFBIWarnTask();
+
+	//自动确认收货
+	@GetMapping("task/autoAffirmReceiveTask")
+    void autoAffirmReceiveTask();
 }

+ 5 - 0
mec-client-api/src/main/java/com/ym/mec/task/fallback/TaskRemoteServiceFallback.java

@@ -175,4 +175,9 @@ public class TaskRemoteServiceFallback implements TaskRemoteService {
 	public void goodsRepertoryFBIWarnTask() {
 		logger.info("商品库存预警推送失败");
 	}
+
+	@Override
+	public void autoAffirmReceiveTask() {
+		logger.info("确认收货执行失败");
+	}
 }

+ 7 - 0
mec-student/src/main/java/com/ym/mec/student/controller/RepairController.java

@@ -158,4 +158,11 @@ public class RepairController extends BaseController {
     public Object getStudentGoodsOrder(Integer goodsSellId) {
         return succeed(studentGoodsSellService.get(goodsSellId));
     }
+
+    @ApiOperation(value = "确认收货")
+    @PostMapping("/affirmReceive")
+    public Object affirmReceive(String orderNo) {
+        studentGoodsSellService.affirmReceive(orderNo);
+        return succeed();
+    }
 }

+ 19 - 0
mec-task/src/main/java/com/ym/mec/task/jobs/AutoAffirmReceiveTask.java

@@ -0,0 +1,19 @@
+package com.ym.mec.task.jobs;
+
+import com.ym.mec.task.TaskRemoteService;
+import com.ym.mec.task.core.BaseTask;
+import com.ym.mec.task.core.TaskException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class AutoAffirmReceiveTask extends BaseTask {
+
+	@Autowired
+	private TaskRemoteService taskRemoteService;
+
+	@Override
+	public void execute() throws TaskException {
+		taskRemoteService.autoAffirmReceiveTask();
+	}
+}

+ 8 - 0
mec-web/src/main/java/com/ym/mec/web/controller/TaskController.java

@@ -75,6 +75,14 @@ public class TaskController extends BaseController {
 
 	@Autowired
 	private GoodsService goodsService;
+	@Autowired
+	private StudentGoodsSellService studentGoodsSellService;
+
+	@GetMapping(value = "/autoAffirmReceiveTask")
+	// 自动确认收货
+	public void affirmReceive(){
+		studentGoodsSellService.affirmReceive(null);
+	}
 
 	@GetMapping(value = "/repertoryWarn")
 	// 商品库存预警