Forráskód Böngészése

Merge branch '20221101' into saas

yonge 2 éve
szülő
commit
ac86afc033

+ 17 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupDeliveryRecordDao.java

@@ -1,9 +1,25 @@
 package com.ym.mec.biz.dal.dao;
 
-import com.ym.mec.common.dal.BaseDAO;
+import java.util.List;
+import java.util.Map;
+
+import com.ym.mec.biz.dal.dto.MusicGroupDeliveryRecordDto;
 import com.ym.mec.biz.dal.entity.MusicGroupDeliveryRecord;
+import com.ym.mec.common.dal.BaseDAO;
 
 public interface MusicGroupDeliveryRecordDao extends BaseDAO<Long, MusicGroupDeliveryRecord> {
 
+	/**
+	 * 通过参数查找结果集,适合分页场景
+	 * @param params
+	 * @return
+	 */
+	public List<MusicGroupDeliveryRecordDto> queryPageList(Map<String, Object> params);
 	
+	/**
+	 * 通过参数查找结果集数目
+	 * @param params
+	 * @return
+	 */
+	public int queryCount(Map<String, Object> params);
 }

+ 10 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SubjectChangeDao.java

@@ -91,4 +91,13 @@ public interface SubjectChangeDao extends BaseDAO<Integer, SubjectChange> {
      * @param musicGroupId
      * @return
      */
-    List<SubjectChange> queryWaitDeliveryList(@Param("musicGroupId") String musicGroupId);}
+    List<SubjectChange> queryWaitDeliveryList(@Param("musicGroupId") String musicGroupId);
+
+    /**
+     * 查询当前乐团指定的发货批次的清单
+     * @param musicGroupId 乐团编号
+     * @param deliveryBatchNo 发货批次号
+     * @return
+     */
+    List<SubjectChange> queryByDeliveryBatchNo(@Param("musicGroupId") String musicGroupId, @Param("deliveryBatchNo") String deliveryBatchNo);
+}

+ 48 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/MusicGroupDeliveryRecordDto.java

@@ -0,0 +1,48 @@
+package com.ym.mec.biz.dal.dto;
+
+import com.ym.mec.biz.dal.entity.MusicGroupDeliveryRecord;
+
+public class MusicGroupDeliveryRecordDto extends MusicGroupDeliveryRecord {
+
+	private String musicGroupShippingAddress;
+	
+	private String operatorUserName;
+	
+	/** 收货人 */
+	private String consigneeName;
+	
+	/** 手机号码 */
+	private String mobile;
+
+	public String getMusicGroupShippingAddress() {
+		return musicGroupShippingAddress;
+	}
+
+	public void setMusicGroupShippingAddress(String musicGroupShippingAddress) {
+		this.musicGroupShippingAddress = musicGroupShippingAddress;
+	}
+
+	public String getOperatorUserName() {
+		return operatorUserName;
+	}
+
+	public void setOperatorUserName(String operatorUserName) {
+		this.operatorUserName = operatorUserName;
+	}
+
+	public String getConsigneeName() {
+		return consigneeName;
+	}
+
+	public void setConsigneeName(String consigneeName) {
+		this.consigneeName = consigneeName;
+	}
+
+	public String getMobile() {
+		return mobile;
+	}
+
+	public void setMobile(String mobile) {
+		this.mobile = mobile;
+	}
+}

+ 36 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/MusicGroupDeliveryRecordQueryInfo.java

@@ -0,0 +1,36 @@
+package com.ym.mec.biz.dal.page;
+
+import com.ym.mec.common.page.QueryInfo;
+
+public class MusicGroupDeliveryRecordQueryInfo extends QueryInfo {
+
+	private String musicGroupId;
+	
+	private String expressCompany;
+	
+	private String expressBillNo;
+
+	public String getMusicGroupId() {
+		return musicGroupId;
+	}
+
+	public void setMusicGroupId(String musicGroupId) {
+		this.musicGroupId = musicGroupId;
+	}
+
+	public String getExpressCompany() {
+		return expressCompany;
+	}
+
+	public void setExpressCompany(String expressCompany) {
+		this.expressCompany = expressCompany;
+	}
+
+	public String getExpressBillNo() {
+		return expressBillNo;
+	}
+
+	public void setExpressBillNo(String expressBillNo) {
+		this.expressBillNo = expressBillNo;
+	}
+}

+ 15 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupDeliveryRecordService.java

@@ -1,8 +1,23 @@
 package com.ym.mec.biz.service;
 
+import java.util.List;
+
+import com.ym.mec.biz.dal.dto.MusicGroupDeliveryRecordDto;
+import com.ym.mec.biz.dal.entity.Goods;
 import com.ym.mec.biz.dal.entity.MusicGroupDeliveryRecord;
+import com.ym.mec.biz.dal.page.MusicGroupDeliveryRecordQueryInfo;
+import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.BaseService;
 
 public interface MusicGroupDeliveryRecordService extends BaseService<Long, MusicGroupDeliveryRecord> {
+	
+	PageInfo<MusicGroupDeliveryRecordDto> queryPage(MusicGroupDeliveryRecordQueryInfo queryInfo);
 
+	/**
+	 * 查询已发货清单
+	 * @param musicGroupId
+	 * @param deliveryBatchNo
+	 * @return
+	 */
+	List<Goods> queryDeliveryList(String musicGroupId, String deliveryBatchNo);
 }

+ 106 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupDeliveryRecordServiceImpl.java

@@ -1,23 +1,129 @@
 package com.ym.mec.biz.service.impl;
 
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import com.ym.mec.biz.dal.dao.MusicGroupDeliveryRecordDao;
+import com.ym.mec.biz.dal.dao.StudentPaymentOrderDetailDao;
+import com.ym.mec.biz.dal.dao.SubjectChangeDao;
+import com.ym.mec.biz.dal.dto.MusicGroupDeliveryRecordDto;
+import com.ym.mec.biz.dal.entity.Goods;
 import com.ym.mec.biz.dal.entity.MusicGroupDeliveryRecord;
+import com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail;
+import com.ym.mec.biz.dal.entity.SubjectChange;
+import com.ym.mec.biz.dal.enums.DealStatusEnum;
+import com.ym.mec.biz.dal.page.MusicGroupDeliveryRecordQueryInfo;
+import com.ym.mec.biz.service.GoodsService;
 import com.ym.mec.biz.service.MusicGroupDeliveryRecordService;
 import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
+import com.ym.mec.util.collection.MapUtil;
 
 @Service
 public class MusicGroupDeliveryRecordServiceImpl extends BaseServiceImpl<Long, MusicGroupDeliveryRecord>  implements MusicGroupDeliveryRecordService {
 	
 	@Autowired
 	private MusicGroupDeliveryRecordDao musicGroupDeliveryRecordDao;
+	
+	@Autowired
+	private StudentPaymentOrderDetailDao studentPaymentOrderDetailDao;
+	
+	@Autowired
+	private SubjectChangeDao subjectChangeDao;
+	
+	@Autowired
+	private GoodsService goodsService;
 
 	@Override
 	public BaseDAO<Long, MusicGroupDeliveryRecord> getDAO() {
 		return musicGroupDeliveryRecordDao;
 	}
+
+	@Override
+	public PageInfo<MusicGroupDeliveryRecordDto> queryPage(MusicGroupDeliveryRecordQueryInfo queryInfo) {
+		PageInfo<MusicGroupDeliveryRecordDto> pageInfo = new PageInfo<MusicGroupDeliveryRecordDto>(queryInfo.getPage(), queryInfo.getRows());
+		Map<String, Object> params = new HashMap<String, Object>();
+		MapUtil.populateMap(params, queryInfo);
+		
+		List<MusicGroupDeliveryRecordDto> dataList = null;
+		int count = this.findCount(params);
+		if (count > 0) {
+			pageInfo.setTotal(count);
+			params.put("offset", pageInfo.getOffset());
+			dataList = musicGroupDeliveryRecordDao.queryPageList(params);
+		}
+		if (count == 0) {
+			dataList = new ArrayList<MusicGroupDeliveryRecordDto>();
+		}
+		pageInfo.setRows(dataList);
+		return pageInfo;
+	}
+
+	@Override
+	public List<Goods> queryDeliveryList(String musicGroupId, String deliveryBatchNo) {
+		
+		//查询subject_change
+		List<SubjectChange> subjectChangeList = subjectChangeDao.queryByDeliveryBatchNo(musicGroupId, deliveryBatchNo);
+		
+		List<Integer> changeUserIdList = null;
+        StringBuilder goodsIdsStr = new StringBuilder();
+		
+		if(subjectChangeList != null && subjectChangeList.size() > 0){
+			changeUserIdList = subjectChangeList.stream().distinct().map(t -> t.getStudentId()).collect(Collectors.toList());
+			
+			for(SubjectChange sc : subjectChangeList) {
+				if(StringUtils.isNotBlank(sc.getChangeAccessories())){
+					goodsIdsStr.append(sc.getChangeAccessories()).append(",");
+				}
+				if(sc.getChangeMusical() != null){
+					goodsIdsStr.append(sc.getChangeMusical()).append(",");
+				}
+			}
+		}
+		
+		//查询student_payment_order_detail,剔除有声部更换的用户
+		List<StudentPaymentOrderDetail> studentPaymentOrderDetailList = studentPaymentOrderDetailDao.findUserApplyOrder(null, musicGroupId, DealStatusEnum.SUCCESS);
+		
+		studentPaymentOrderDetailList = studentPaymentOrderDetailList.stream().filter((t) -> StringUtils.isNotBlank(t.getGoodsIdList()) && StringUtils.equals(t.getDeliveryBatchNo(), deliveryBatchNo)).collect(Collectors.toList());
+		
+		if(changeUserIdList != null && changeUserIdList.size() > 0){
+			Iterator<StudentPaymentOrderDetail> iterator = studentPaymentOrderDetailList.iterator();
+			
+			while(iterator.hasNext()){
+				if(changeUserIdList.contains(iterator.next().getUserId())){
+					iterator.remove();
+				}
+			}
+		}
+		
+		for(StudentPaymentOrderDetail spod : studentPaymentOrderDetailList){
+			goodsIdsStr.append(spod.getGoodsIdList()).append(",");
+		}
+		
+		List<Goods> goodsList = goodsService.findGoodsByIds(goodsIdsStr.toString());
+		Map<Integer, Goods> goodsMap = goodsList.stream().collect(Collectors.toMap(Goods::getId, t -> t));
+
+		Goods g = null;
+		for (String goodsId : goodsIdsStr.toString().split(",")) {
+			g = goodsMap.get(Integer.parseInt(goodsId));
+			
+			if(g == null) continue;
+			
+			g.setSellCount(g.getSellCount() + 1);
+			
+			goodsMap.put(g.getId(), g);
+		}
+		
+		return new ArrayList<Goods>(goodsMap.values());
+	}
 	
 }

+ 60 - 3
mec-biz/src/main/resources/config/mybatis/MusicGroupDeliveryRecordMapper.xml

@@ -15,6 +15,13 @@
 		<result column="update_time_" property="updateTime" />
 		<result column="create_time_" property="createTime" />
 	</resultMap>
+	
+	<resultMap type="com.ym.mec.biz.dal.dto.MusicGroupDeliveryRecordDto" id="MusicGroupDeliveryRecordDto" extends="MusicGroupDeliveryRecord">
+		<result column="address_name_" property="musicGroupShippingAddress" />
+		<result column="operator_name_" property="operatorUserName" />
+		<result column="consignee_name_" property="consigneeName" />
+		<result column="mobile_" property="mobile" />
+	</resultMap>
 
 	<!-- 根据主键查询一条记录 -->
 	<select id="get" resultMap="MusicGroupDeliveryRecord">
@@ -82,13 +89,63 @@
 	<!-- 分页查询 -->
 	<select id="queryPage" resultMap="MusicGroupDeliveryRecord"
 		parameterType="map">
-		SELECT * FROM music_group_delivery_record ORDER BY id_
+		SELECT * FROM music_group_delivery_record
+		<where>
+			<if test="musicGroupId != null and musicGroupId != ''">
+				and music_group_id_ = #{musicGroupId}
+			</if>
+			<if test="expressCompany != null and expressCompany != ''">
+				and express_company_ = #{expressCompany}
+			</if>
+			<if test="expressBillNo != null and expressBillNo != ''">
+				and express_bill_no_ = #{expressBillNo}
+			</if>
+		</where>
+		 ORDER BY id_
+		<include refid="global.limit" />
+	</select>
+
+	<!-- 分页查询 -->
+	<select id="queryPageList" resultMap="MusicGroupDeliveryRecordDto"
+		parameterType="map">
+		SELECT mgdr.*,u.real_name_ operator_name_,a.address_name_,a.consignee_name_,a.mobile_ FROM music_group_delivery_record mgdr
+		left join sys_user u on u.id_ = mgdr.operator_user_id_
+		left join 
+		(
+		SELECT sa.*,concat(pa.name_,ca.name_,coa.name_,sa.detail_address_) address_name_ FROM music_group_shipping_address sa 
+		left join sys_area pa on sa.region_province_id_ = pa.id_
+		left join sys_area ca on sa.region_city_id_ = ca.id_
+		left join sys_area coa on sa.region_county_id_ = coa.id_
+		where sa.del_flag_ = 0 and sa.music_group_id_ = #{musicGroupId}
+		) a on a.id_ = mgdr.music_group_shipping_address_id_
+		<where>
+			<if test="musicGroupId != null and musicGroupId != ''">
+				and mgdr.music_group_id_ = #{musicGroupId}
+			</if>
+			<if test="expressCompany != null and expressCompany != ''">
+				and mgdr.express_company_ = #{expressCompany}
+			</if>
+			<if test="expressBillNo != null and expressBillNo != ''">
+				and mgdr.express_bill_no_ = #{expressBillNo}
+			</if>
+		</where>
+		 ORDER BY id_
 		<include refid="global.limit" />
 	</select>
 
 	<!-- 查询当前表的总记录数 -->
 	<select id="queryCount" resultType="int">
-		SELECT COUNT(*) FROM
-		music_group_delivery_record
+		SELECT COUNT(mgdr.id_) FROM music_group_delivery_record mgdr
+		<where>
+			<if test="musicGroupId != null and musicGroupId != ''">
+				and mgdr.music_group_id_ = #{musicGroupId}
+			</if>
+			<if test="expressCompany != null and expressCompany != ''">
+				and mgdr.express_company_ = #{expressCompany}
+			</if>
+			<if test="expressBillNo != null and expressBillNo != ''">
+				and mgdr.express_bill_no_ = #{expressBillNo}
+			</if>
+		</where>
 	</select>
 </mapper>

+ 6 - 3
mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderDetailMapper.xml

@@ -225,11 +225,14 @@
 
     <!-- 查询用户注册订单详情 -->
     <select id="findUserApplyOrder" resultMap="StudentPaymentOrderDetail">
-        SELECT spod.*
+        SELECT spod.*,spo.user_id_
         FROM student_payment_order_detail spod
                  LEFT JOIN student_payment_order spo ON spo.id_ = spod.payment_order_id_
-        WHERE spo.user_id_ = #{userId}
-          AND spo.music_group_id_ = #{musicGroupId}
+        WHERE 
+          spo.music_group_id_ = #{musicGroupId}
+          <if test="userId != null">
+          AND	spo.user_id_ = #{userId}
+          </if>
           AND spo.status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
           AND spo.type_ = 'APPLY'
     </select>

+ 11 - 0
mec-biz/src/main/resources/config/mybatis/SubjectChangeMapper.xml

@@ -446,5 +446,16 @@
         WHERE music_group_id_ = #{musicGroupId}
           AND status_ = 2 and delivery_batch_no_ is NULL
     </select>
+
+    <select id="queryByDeliveryBatchNo" resultMap="SubjectChange">
+        SELECT sc.* FROM subject_change sc
+        WHERE sc.id_ IN (
+            SELECT MAX(id_)
+            FROM subject_change
+            WHERE music_group_id_ = #{musicGroupId} and delivery_batch_no_ = #{deliveryBatchNo}
+              AND status_ = 2
+            GROUP BY student_id_
+        )
+    </select>
     
 </mapper>

+ 34 - 0
mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupDeliveryRecordController.java

@@ -0,0 +1,34 @@
+package com.ym.mec.web.controller;
+
+import io.swagger.annotations.Api;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.ym.mec.biz.dal.dto.MusicGroupDeliveryRecordDto;
+import com.ym.mec.biz.dal.page.MusicGroupDeliveryRecordQueryInfo;
+import com.ym.mec.biz.service.MusicGroupDeliveryRecordService;
+import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.entity.HttpResponseResult;
+import com.ym.mec.common.page.PageInfo;
+@RequestMapping("musicGroupDeliveryRecord")
+@Api(tags = "乐团发货记录")
+@RestController
+public class MusicGroupDeliveryRecordController extends BaseController {
+
+	@Autowired
+	private MusicGroupDeliveryRecordService musicGroupDeliveryRecordService;
+	
+	@GetMapping("/queryPage")
+	public HttpResponseResult<PageInfo<MusicGroupDeliveryRecordDto>> queryPage(MusicGroupDeliveryRecordQueryInfo queryInfo) {
+		return succeed(musicGroupDeliveryRecordService.queryPage(queryInfo));
+	}
+	
+	@GetMapping("/queryGoodsDetail")
+	public Object queryGoodsDetail(String musicGroupId, String deliveryBatchNo) {
+		
+		return succeed(musicGroupDeliveryRecordService.queryDeliveryList(musicGroupId, deliveryBatchNo));
+	}
+}