Browse Source

Merge remote-tracking branch 'origin/master_saas' into master_saas

zouxuan 2 năm trước cách đây
mục cha
commit
1550f6d22f
21 tập tin đã thay đổi với 219 bổ sung68 xóa
  1. 4 0
      mec-biz/src/main/java/com/ym/mec/biz/service/StudentPaymentOrderService.java
  2. 4 17
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java
  3. 17 6
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleTeacherSalaryServiceImpl.java
  4. 7 5
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java
  5. 20 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderServiceImpl.java
  6. 5 12
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/TeacherDefaultMusicGroupSalaryServiceImpl.java
  7. 2 0
      mec-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml
  8. 1 1
      mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderMapper.xml
  9. 3 2
      mec-client-api/src/main/java/com/ym/mec/web/WebFeignService.java
  10. 2 1
      mec-client-api/src/main/java/com/ym/mec/web/fallback/WebFeignServiceFallback.java
  11. 40 0
      mec-common/common-core/src/main/java/com/ym/mec/common/entity/RefundModel.java
  12. 3 0
      mec-mall/mall-admin/src/main/java/com/yonge/cooleshow/admin/controller/UmsRoleController.java
  13. 18 0
      mec-mall/mall-admin/src/main/java/com/yonge/cooleshow/admin/service/impl/PmsProductServiceImpl.java
  14. 2 1
      mec-mall/mall-admin/src/main/java/com/yonge/cooleshow/admin/service/impl/UmsAdminServiceImpl.java
  15. 3 1
      mec-mall/mall-admin/src/main/java/com/yonge/cooleshow/admin/service/impl/UmsRoleServiceImpl.java
  16. 11 0
      mec-mall/mall-mbg/src/main/java/com/yonge/cooleshow/mbg/model/UmsAdmin.java
  17. 22 7
      mec-mall/mall-mbg/src/main/resources/config/mybatis/UmsAdminMapper.xml
  18. 4 3
      mec-mall/mall-portal/src/main/java/com/yonge/cooleshow/portal/controller/PaymentController.java
  19. 12 7
      mec-mall/mall-portal/src/main/java/com/yonge/cooleshow/portal/service/impl/OmsPortalOrderServiceImpl.java
  20. 34 1
      mec-thirdparty/src/main/java/com/ym/mec/thirdparty/adapay/Payment.java
  21. 5 4
      mec-web/src/main/java/com/ym/mec/web/controller/APIController.java

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

@@ -18,6 +18,7 @@ import com.ym.mec.common.entity.MallCreateOrderModel;
 import com.ym.mec.common.entity.OrderCancelModel;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.BaseService;
+import com.ym.mec.thirdparty.adapay.entity.BaseResult;
 import com.ym.mec.thirdparty.adapay.entity.HfMerchantConfig;
 import org.apache.ibatis.annotations.Param;
 
@@ -248,4 +249,7 @@ public interface StudentPaymentOrderService extends BaseService<Long, StudentPay
     void mallSaveOrderInfo(MallCreateOrderModel model);
 
     OrderCancelModel cancelOrder(StudentPaymentOrder orderByOrderNo);
+
+    // 撤销支付
+    BaseResult<Map<String, Object>> refund(String orderNo, String notifyUrl, String refundNo);
 }

+ 4 - 17
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java

@@ -730,11 +730,6 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 								}
 							} else if (StringUtils.equals(settlementType, "GRADIENT_SALARY")) {
 								unitMinutes = 90;
-								if (type == CourseScheduleType.CLASSROOM) {
-									unitMinutes = 40;
-								} else if (type == CourseScheduleType.HIGH) {
-									unitMinutes = 45;
-								}
 								if (courseScheduleTeacherSalary.getTeacherRole() == TeachTypeEnum.BISHOP) {
 									courseScheduleTeacherSalary.setExpectSalary(new BigDecimal(tdms.getMainTeacher90MinSalary().doubleValue() * newMinutes
 											/ unitMinutes));
@@ -750,19 +745,11 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 								courseScheduleTeacherSalary.setExpectSalary(salary);
 							}
 							//基础技能提高课
-							/*if (type == CourseScheduleType.HIGH) {
-								BigDecimal salary = courseScheduleTeacherSalary.getTeacherRole().equals(TeachTypeEnum.BISHOP) ? tdms.getMainTeacher30MinSalary() : tdms.getAssistantTeacher30MinSalary();
-								if (StringUtils.equals(settlementType, "GRADIENT_SALARY")) {
-									salary = courseScheduleTeacherSalary.getTeacherRole().equals(TeachTypeEnum.BISHOP) ? tdms.getMainTeacher90MinSalary() : tdms.getAssistantTeacher90MinSalary();
-								}
-								int studentNum = courseScheduleStudentPaymentDao.countCourseOnlyStudentNum(courseSchedule.getId());
-								if(studentNum<=0){
-									studentNum = classGroupStudentMapperDao.countClassGroupNormalStudentNum(courseSchedule.getClassGroupId());
-								}
-								courseScheduleTeacherSalary.setExpectSalary(salary.multiply(new BigDecimal(studentNum)));
-							}*/
-							//线上小班课
 							if(type == CourseScheduleType.HIGH_ONLINE || type == CourseScheduleType.HIGH){
+								
+								if(StringUtils.isBlank(tdms.getSalaryRuleJson())){
+				            		throw new BizException("线上基础技能课课酬设置异常");
+				                }
 								int studentNum = courseScheduleStudentPaymentDao.countCourseOnlyStudentNum(courseSchedule.getId());
 								if(studentNum<=0){
 									studentNum = classGroupStudentMapperDao.countClassGroupNormalStudentNum(courseSchedule.getClassGroupId());

+ 17 - 6
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleTeacherSalaryServiceImpl.java

@@ -7,6 +7,7 @@ import com.ym.mec.biz.dal.dao.*;
 import com.ym.mec.biz.dal.dto.*;
 import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.entity.SalarySettlementDto;
+import com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType;
 import com.ym.mec.biz.dal.enums.*;
 import com.ym.mec.biz.dal.page.CourseSalaryQueryInfo4Web;
 import com.ym.mec.biz.dal.page.CourseScheduleTeacherSalaryQueryInfo;
@@ -1314,10 +1315,10 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
             }
 
             //课堂课课酬改为按分钟数计算,并且时长占比向下取整
-            if (courseSchedule.getType().equals(CourseSchedule.CourseScheduleType.CLASSROOM)){
+            /*if (courseSchedule.getType().equals(CourseSchedule.CourseScheduleType.CLASSROOM)){
                 baseSalary = TeachTypeEnum.BISHOP.equals(courseScheduleTeacherSalary.getTeacherRole()) ? teacherDefaultMusicGroupSalary.getMainTeacher90MinSalary() : teacherDefaultMusicGroupSalary.getAssistantTeacher90MinSalary();
                 classTimeDuty = new BigDecimal(classCourseDuration).divide(new BigDecimal(40), BigDecimal.ZERO.intValue(), BigDecimal.ROUND_DOWN);
-            }
+            }*/
             
             if(Objects.isNull(baseSalary)){
                 throw new BizException("课酬设置异常");
@@ -1325,7 +1326,12 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
 
             salary = baseSalary.multiply(classTimeDuty).setScale(2, BigDecimal.ROUND_HALF_UP);
 
-            //基础技能提高课
+			//课堂课课酬
+			if (courseSchedule.getType() == CourseScheduleType.CLASSROOM) {
+				salary = TeachTypeEnum.BISHOP.equals(courseScheduleTeacherSalary.getTeacherRole()) ? teacherDefaultMusicGroupSalary.getMainTeacher90MinSalary() : teacherDefaultMusicGroupSalary.getAssistantTeacher90MinSalary();
+			}
+
+            /*//基础技能提高课
             if (courseSchedule.getType().equals(CourseSchedule.CourseScheduleType.HIGH)) {
                 salary = TeachTypeEnum.BISHOP.equals(courseScheduleTeacherSalary.getTeacherRole()) ? teacherDefaultMusicGroupSalary.getMainTeacher30MinSalary() : teacherDefaultMusicGroupSalary.getAssistantTeacher30MinSalary();
                 if (settlementType.equals(SalarySettlementTypeEnum.GRADIENT_SALARY)) {
@@ -1342,9 +1348,14 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
                     studentNum=5;
                 }
                 salary = salary.multiply(new BigDecimal(studentNum));
-            }
-            //线上小班课
-            if (courseSchedule.getType().equals(CourseSchedule.CourseScheduleType.HIGH_ONLINE)) {
+            }*/
+            //基础技能提高课
+            if (courseSchedule.getType() == CourseSchedule.CourseScheduleType.HIGH_ONLINE || courseSchedule.getType() == CourseSchedule.CourseScheduleType.HIGH) {
+            	
+            	if(StringUtils.isBlank(teacherDefaultMusicGroupSalary.getSalaryRuleJson())){
+            		throw new BizException("线上基础技能课课酬设置异常");
+            	}
+            	
                 int studentNum = courseScheduleStudentPaymentDao.countCourseOnlyStudentNum(courseSchedule.getId());
                 if(studentNum<=0){
                     studentNum = classGroupStudentMapperDao.countClassGroupNormalStudentNum(courseSchedule.getClassGroupId());

+ 7 - 5
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -1885,7 +1885,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             throw new BizException("乐团找不到");
         }
 
-        if (musicGroup.getStatus() != MusicGroupStatusEnum.PAUSE) {
+        if (musicGroup.getStatus() != MusicGroupStatusEnum.PAUSE && musicGroup.getStatus() != MusicGroupStatusEnum.CLOSE) {
             throw new BizException("乐团当前状态是{},不能恢复", musicGroup.getStatus().getMsg());
         }
 
@@ -1905,7 +1905,9 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroupId, "恢复乐团", sysUser.getId(), ""));
 
         //恢复课表
-        courseScheduleDao.resumeCourseScheduleByMusicGroupId(musicGroup.getId());
+        if (musicGroup.getStatus() == MusicGroupStatusEnum.PAUSE) {
+        	courseScheduleDao.resumeCourseScheduleByMusicGroupId(musicGroup.getId());
+        }
 
         //统计变更学员数
         groupEventSource.musicGroupStudentChangeEvent(musicGroupId, StudentMusicGroupStatusEnum.NORMAL, null);
@@ -3768,13 +3770,13 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         }
 
         //删除未上课表
-        courseScheduleDao.logicDeleteCourseSchedulesByMusicGroupID(musicGroup.getId());
+        courseScheduleDao.deleteCourseSchedulesByMusicGroupID(musicGroup.getId(), null);
 
         //将学生退团
-        List<StudentRegistration> registrations = studentRegistrationDao.findClassGroupStu(musicGroup.getId(), null);
+        /*List<StudentRegistration> registrations = studentRegistrationDao.findClassGroupStu(musicGroup.getId(), null);
         if (registrations.size() > 0 && studentRegistrationService.quitAllStudent(musicGroup.getId(), "退团(乐团关闭)") <= 0) {
             throw new BizException("处理学生退团失败,请重试");
-        }
+        }*/
 
         //统计变更学员数
         groupEventSource.musicGroupStudentChangeEvent(closeMusicGroupDto.getMusicGroupId(), StudentMusicGroupStatusEnum.QUIT, null);

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

@@ -27,6 +27,7 @@ import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.common.tenant.TenantContextHolder;
 import com.ym.mec.thirdparty.adapay.ConfigInit;
 import com.ym.mec.thirdparty.adapay.Payment;
+import com.ym.mec.thirdparty.adapay.entity.BaseResult;
 import com.ym.mec.thirdparty.adapay.entity.HfMerchantConfig;
 import com.ym.mec.thirdparty.yqpay.*;
 import com.ym.mec.util.collection.MapUtil;
@@ -1237,4 +1238,23 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
         }
         return model;
     }
+
+    @Override
+    public BaseResult<Map<String, Object>> refund(String orderNo, String notifyUrl, String refundNo) {
+
+        StudentPaymentOrder orderByOrderNo = studentPaymentOrderService.findOrderByOrderNo(orderNo);
+        if (orderByOrderNo == null) {
+            throw new BizException("为找到订单");
+        }
+        if (orderByOrderNo.getActualAmount().compareTo(BigDecimal.ZERO) ==0) {
+            throw new BizException("0元订单");
+        }
+
+        HfMerchantConfig hfMerchantConfig = hfMerchantConfigService.queryByTenantId(orderByOrderNo.getTenantId());
+        if(hfMerchantConfig == null){
+            throw new BizException("请配置机构的汇付商户信息");
+        }
+        return Payment.reversePayment(orderByOrderNo.getTransNo(),hfMerchantConfig.getAppId(),refundNo,
+                               orderByOrderNo.getActualAmount().setScale(2,BigDecimal.ROUND_HALF_UP).toString(),notifyUrl);
+    }
 }

+ 5 - 12
mec-biz/src/main/java/com/ym/mec/biz/service/impl/TeacherDefaultMusicGroupSalaryServiceImpl.java

@@ -9,8 +9,6 @@ import java.util.Map;
 import java.util.Set;
 import java.util.stream.Collectors;
 
-import com.ym.mec.biz.dal.dao.*;
-import com.ym.mec.biz.dal.entity.CourseSchedule;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -19,6 +17,11 @@ import org.springframework.transaction.annotation.Transactional;
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
+import com.ym.mec.biz.dal.dao.ClassGroupStudentMapperDao;
+import com.ym.mec.biz.dal.dao.CourseScheduleStudentPaymentDao;
+import com.ym.mec.biz.dal.dao.CourseScheduleTeacherSalaryDao;
+import com.ym.mec.biz.dal.dao.MusicGroupDao;
+import com.ym.mec.biz.dal.dao.TeacherDefaultMusicGroupSalaryDao;
 import com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType;
 import com.ym.mec.biz.dal.entity.CourseScheduleTeacherSalary;
 import com.ym.mec.biz.dal.entity.MusicGroup;
@@ -170,11 +173,6 @@ public class TeacherDefaultMusicGroupSalaryServiceImpl extends BaseServiceImpl<L
 										int studentNum = courseScheduleStudentPaymentDao.countCourseOnlyStudentNum(ts.getCourseScheduleId());
 										ts.setExpectSalary(ts.getExpectSalary().multiply(new BigDecimal(studentNum)));
 									}*/
-									//课堂课课酬改为按分钟数计算,并且时长占比向下取整
-									if (CourseSchedule.CourseScheduleType.CLASSROOM.equals(tdms.getCourseScheduleType())){
-										ts.setExpectSalary(TeachTypeEnum.BISHOP.equals(ts.getTeacherRole()) ? tdms.getMainTeacher90MinSalary() : tdms.getAssistantTeacher90MinSalary());
-										ts.setExpectSalary(duration.divide(new BigDecimal(40), BigDecimal.ZERO.intValue(), BigDecimal.ROUND_DOWN).multiply(ts.getExpectSalary()).setScale(2, BigDecimal.ROUND_HALF_UP));
-									}
 									list.add(ts);
 								} else if (musicGroup.getSettlementType() == SalarySettlementTypeEnum.TEACHER_DEFAULT) {// 默认课酬
 									mins = 30;
@@ -197,11 +195,6 @@ public class TeacherDefaultMusicGroupSalaryServiceImpl extends BaseServiceImpl<L
 										int studentNum = courseScheduleStudentPaymentDao.countCourseOnlyStudentNum(ts.getCourseScheduleId());
 										ts.setExpectSalary(ts.getExpectSalary().multiply(new BigDecimal(studentNum)));
 									}*/
-									//课堂课课酬改为按分钟数计算,并且时长占比向下取整
-									if (CourseSchedule.CourseScheduleType.CLASSROOM.equals(tdms.getCourseScheduleType())){
-										ts.setExpectSalary(TeachTypeEnum.BISHOP.equals(ts.getTeacherRole()) ? tdms.getMainTeacher90MinSalary() : tdms.getAssistantTeacher90MinSalary());
-										ts.setExpectSalary(duration.divide(new BigDecimal(40), BigDecimal.ZERO.intValue(), BigDecimal.ROUND_DOWN).multiply(ts.getExpectSalary()).setScale(2, BigDecimal.ROUND_HALF_UP));
-									}
 									list.add(ts);
 								}
 								if(ts.getExpectSalary() == null){

+ 2 - 0
mec-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml

@@ -314,7 +314,9 @@
         DELETE
         FROM course_schedule
         WHERE music_group_id_ = #{musicGroupId}
+        <if test="groupType != null">
           AND group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+        </if>
           and status_ = 'NOT_START'
     </delete>
 

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

@@ -1049,7 +1049,7 @@
         from student_payment_order as a
                  left join
              student_payment_order_detail as b on a.id_ = b.payment_order_id_
-        where order_no_ = #{orderNo}
+        where a.order_no_ = #{orderNo}
     </select>
     <select id="getStudentMusicOrderNum" resultType="int">
         SELECT COUNT(0) FROM student_payment_order spo

+ 3 - 2
mec-client-api/src/main/java/com/ym/mec/web/WebFeignService.java

@@ -4,6 +4,7 @@ import com.ym.mec.common.config.FeignConfiguration;
 import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.entity.MallCreateOrderModel;
 import com.ym.mec.common.entity.OrderCancelModel;
+import com.ym.mec.common.entity.RefundModel;
 import com.ym.mec.common.page.QueryInfo;
 import com.ym.mec.thirdparty.adapay.entity.BaseResult;
 import com.ym.mec.thirdparty.adapay.entity.HfMerchantConfig;
@@ -63,6 +64,6 @@ public interface WebFeignService {
 	HttpResponseResult<Map<String,String>> getBaseUrl(@RequestParam("orderNo") String orderNo);
 
 	// 商城获取 退款数据
-	@GetMapping("/api/refund")
-	public HttpResponseResult<BaseResult<Map<String, Object>>> refund(@RequestParam Map<String,Object> refundInfo);
+	@PostMapping("/api/refund")
+	HttpResponseResult<BaseResult<Map<String, Object>>> refund(@RequestBody RefundModel refundModel);
 }

+ 2 - 1
mec-client-api/src/main/java/com/ym/mec/web/fallback/WebFeignServiceFallback.java

@@ -3,6 +3,7 @@ package com.ym.mec.web.fallback;
 import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.entity.MallCreateOrderModel;
 import com.ym.mec.common.entity.OrderCancelModel;
+import com.ym.mec.common.entity.RefundModel;
 import com.ym.mec.common.page.QueryInfo;
 import com.ym.mec.thirdparty.adapay.entity.BaseResult;
 import com.ym.mec.thirdparty.adapay.entity.HfMerchantConfig;
@@ -88,7 +89,7 @@ public class WebFeignServiceFallback implements WebFeignService {
 	}
 
 	@Override
-	public HttpResponseResult<BaseResult<Map<String, Object>>> refund(Map<String, Object> refundInfo) {
+	public HttpResponseResult<BaseResult<Map<String, Object>>> refund(RefundModel refundModel) {
 		return null;
 	}
 }

+ 40 - 0
mec-common/common-core/src/main/java/com/ym/mec/common/entity/RefundModel.java

@@ -0,0 +1,40 @@
+package com.ym.mec.common.entity;
+
+import java.io.Serializable;
+
+/**
+ * Description
+ *
+ * @author liujunchi
+ * @date 2022-09-22
+ */
+public class RefundModel implements Serializable {
+
+    private String orderNo;
+    private String notifyUrl;
+    private String refundNo;
+
+    public String getOrderNo() {
+        return orderNo;
+    }
+
+    public void setOrderNo(String orderNo) {
+        this.orderNo = orderNo;
+    }
+
+    public String getNotifyUrl() {
+        return notifyUrl;
+    }
+
+    public void setNotifyUrl(String notifyUrl) {
+        this.notifyUrl = notifyUrl;
+    }
+
+    public String getRefundNo() {
+        return refundNo;
+    }
+
+    public void setRefundNo(String refundNo) {
+        this.refundNo = refundNo;
+    }
+}

+ 3 - 0
mec-mall/mall-admin/src/main/java/com/yonge/cooleshow/admin/controller/UmsRoleController.java

@@ -52,6 +52,9 @@ public class UmsRoleController {
         if (ids.stream().anyMatch(id -> id.equals(1L))) {
             return CommonResult.failed("默认角色不能删除");
         }
+        if (ids.stream().anyMatch(id -> id.equals(9L))) {
+            return CommonResult.failed("默认角色不能删除");
+        }
         int count = roleService.delete(ids);
         if (count > 0) {
             return CommonResult.success(count);

+ 18 - 0
mec-mall/mall-admin/src/main/java/com/yonge/cooleshow/admin/service/impl/PmsProductServiceImpl.java

@@ -2,6 +2,7 @@ package com.yonge.cooleshow.admin.service.impl;
 
 import cn.hutool.core.collection.CollUtil;
 import com.github.pagehelper.PageHelper;
+import com.ym.mec.common.exception.BizException;
 import com.yonge.cooleshow.admin.dao.*;
 import com.yonge.cooleshow.admin.dao.*;
 import com.yonge.cooleshow.admin.dto.HomeStatistical;
@@ -19,6 +20,7 @@ import org.springframework.util.CollectionUtils;
 import org.springframework.util.StringUtils;
 
 import java.lang.reflect.Method;
+import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
@@ -69,6 +71,14 @@ public class PmsProductServiceImpl implements PmsProductService {
 
     @Override
     public int create(PmsProductParam productParam) {
+        if (productParam.getPrice().compareTo(BigDecimal.ZERO) <=0 ) {
+            throw new BizException("商品价格不能小于等于0");
+        }
+        for (PmsSkuStock pmsSkuStock : productParam.getSkuStockList()) {
+            if (pmsSkuStock.getPrice().compareTo(BigDecimal.ZERO) <= 0) {
+                throw new BizException("商品价格不能小于等于0");
+            }
+        }
         int count;
         //创建商品
         productParam.setId(null);
@@ -122,6 +132,14 @@ public class PmsProductServiceImpl implements PmsProductService {
 
     @Override
     public int update(Long id, PmsProductParam productParam) {
+        if (productParam.getPrice().compareTo(BigDecimal.ZERO) <=0 ) {
+            throw new BizException("商品价格不能小于等于0");
+        }
+        for (PmsSkuStock pmsSkuStock : productParam.getSkuStockList()) {
+            if (pmsSkuStock.getPrice().compareTo(BigDecimal.ZERO) <= 0) {
+                throw new BizException("商品价格不能小于等于0");
+            }
+        }
         int count;
         //更新商品信息
         PmsProduct product = productParam;

+ 2 - 1
mec-mall/mall-admin/src/main/java/com/yonge/cooleshow/admin/service/impl/UmsAdminServiceImpl.java

@@ -244,6 +244,7 @@ public class UmsAdminServiceImpl implements UmsAdminService {
         admin.setNickName(row.getUsername());
         admin.setPassword(row.getPassword());
         admin.setStatus(1);
+        admin.setPhone(row.getPhone());
         admin.setIcon(row.getAvatar());
         return admin;
     }
@@ -280,7 +281,7 @@ public class UmsAdminServiceImpl implements UmsAdminService {
         for (Long adminId : adminIdList) {
             UmsAdminRoleRelation roleRelation = new UmsAdminRoleRelation();
             roleRelation.setAdminId(adminId);
-            roleRelation.setRoleId(1L);
+            roleRelation.setRoleId(9L);
             list.add(roleRelation);
         }
         return adminRoleRelationDao.insertList(list) > 0;

+ 3 - 1
mec-mall/mall-admin/src/main/java/com/yonge/cooleshow/admin/service/impl/UmsRoleServiceImpl.java

@@ -56,7 +56,9 @@ public class UmsRoleServiceImpl implements UmsRoleService {
 
     @Override
     public List<UmsRole> list() {
-        return roleMapper.selectByExample(new UmsRoleExample());
+        UmsRoleExample umsRoleExample = new UmsRoleExample();
+        umsRoleExample.createCriteria().andStatusEqualTo(1);
+        return roleMapper.selectByExample(umsRoleExample);
     }
 
     @Override

+ 11 - 0
mec-mall/mall-mbg/src/main/java/com/yonge/cooleshow/mbg/model/UmsAdmin.java

@@ -32,8 +32,19 @@ public class UmsAdmin implements Serializable {
     @ApiModelProperty(value = "帐号启用状态:0->禁用;1->启用")
     private Integer status;
 
+    @ApiModelProperty("手机号")
+    private String phone;
+
     private static final long serialVersionUID = 1L;
 
+    public String getPhone() {
+        return phone;
+    }
+
+    public void setPhone(String phone) {
+        this.phone = phone;
+    }
+
     public Long getId() {
         return id;
     }

+ 22 - 7
mec-mall/mall-mbg/src/main/resources/config/mybatis/UmsAdminMapper.xml

@@ -8,6 +8,7 @@
     <result column="icon" jdbcType="VARCHAR" property="icon" />
     <result column="email" jdbcType="VARCHAR" property="email" />
     <result column="nick_name" jdbcType="VARCHAR" property="nickName" />
+    <result column="phone" jdbcType="VARCHAR" property="phone" />
     <result column="note" jdbcType="VARCHAR" property="note" />
     <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
     <result column="login_time" jdbcType="TIMESTAMP" property="loginTime" />
@@ -72,7 +73,7 @@
     </where>
   </sql>
   <sql id="Base_Column_List">
-    id, username, password, icon, email, nick_name, note, create_time, login_time, status
+    id, username, password, icon, email, nick_name, note, create_time, login_time, status,phone
   </sql>
   <select id="selectByExample" parameterType="com.yonge.cooleshow.mbg.model.UmsAdminExample" resultMap="BaseResultMap">
     select
@@ -110,11 +111,11 @@
     </selectKey>
     insert into ums_admin (username, password, icon, 
       email, nick_name, note, 
-      create_time, login_time, status
+      create_time, login_time, status,phone
       )
     values (#{username,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, #{icon,jdbcType=VARCHAR}, 
       #{email,jdbcType=VARCHAR}, #{nickName,jdbcType=VARCHAR}, #{note,jdbcType=VARCHAR}, 
-      #{createTime,jdbcType=TIMESTAMP}, #{loginTime,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER}
+      #{createTime,jdbcType=TIMESTAMP}, #{loginTime,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER},#{phone}
       )
   </insert>
   <insert id="insertSelective" parameterType="com.yonge.cooleshow.mbg.model.UmsAdmin">
@@ -150,6 +151,9 @@
       <if test="status != null">
         status,
       </if>
+      <if test="phone != null">
+        phone,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
       <if test="username != null">
@@ -179,6 +183,9 @@
       <if test="status != null">
         #{status,jdbcType=INTEGER},
       </if>
+      <if test="phone != null">
+        #{phone},
+      </if>
     </trim>
   </insert>
   <select id="countByExample" parameterType="com.yonge.cooleshow.mbg.model.UmsAdminExample" resultType="java.lang.Long">
@@ -220,6 +227,9 @@
       <if test="record.status != null">
         status = #{record.status,jdbcType=INTEGER},
       </if>
+      <if test="record.phone != null">
+        phone = #{record.phone},
+      </if>
     </set>
     <if test="_parameter != null">
       <include refid="Update_By_Example_Where_Clause" />
@@ -236,6 +246,7 @@
       note = #{record.note,jdbcType=VARCHAR},
       create_time = #{record.createTime,jdbcType=TIMESTAMP},
       login_time = #{record.loginTime,jdbcType=TIMESTAMP},
+      phone = #{record.phone},
       status = #{record.status,jdbcType=INTEGER}
     <if test="_parameter != null">
       <include refid="Update_By_Example_Where_Clause" />
@@ -271,6 +282,9 @@
       <if test="status != null">
         status = #{status,jdbcType=INTEGER},
       </if>
+      <if test="phone != null">
+        phone = #{phone},
+      </if>
     </set>
     where id = #{id,jdbcType=BIGINT}
   </update>
@@ -284,6 +298,7 @@
       note = #{note,jdbcType=VARCHAR},
       create_time = #{createTime,jdbcType=TIMESTAMP},
       login_time = #{loginTime,jdbcType=TIMESTAMP},
+      phone = #{phone},
       status = #{status,jdbcType=INTEGER}
     where id = #{id,jdbcType=BIGINT}
   </update>
@@ -291,24 +306,24 @@
   <insert id="addRootAdmin"  parameterType="com.yonge.cooleshow.mbg.model.UmsAdmin">
     insert into ums_admin (id,username, password, icon,
     email, nick_name, note,
-    create_time, login_time, status
+    create_time, login_time, status,phone
     )
     values (#{id,jdbcType=BIGINT},#{username,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, #{icon,jdbcType=VARCHAR},
     #{email,jdbcType=VARCHAR}, #{nickName,jdbcType=VARCHAR}, #{note,jdbcType=VARCHAR},
-    #{createTime,jdbcType=TIMESTAMP}, #{loginTime,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER}
+    #{createTime,jdbcType=TIMESTAMP}, #{loginTime,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER},#{phone}
     )
   </insert>
 
   <insert id="saveRootAdminList">
     replace into ums_admin (id,username, password, icon,
     email, nick_name, note,
-    create_time, login_time, status
+    create_time, login_time, status,phone
     )
     values
     <foreach collection="adminList" separator="," close="" open="" item="item">
       (#{item.id,jdbcType=BIGINT},#{item.username,jdbcType=VARCHAR}, #{item.password,jdbcType=VARCHAR}, #{item.icon,jdbcType=VARCHAR},
       #{item.email,jdbcType=VARCHAR}, #{item.nickName,jdbcType=VARCHAR}, #{item.note,jdbcType=VARCHAR},
-      #{item.createTime,jdbcType=TIMESTAMP}, #{item.loginTime,jdbcType=TIMESTAMP}, #{item.status,jdbcType=INTEGER}
+      #{item.createTime,jdbcType=TIMESTAMP}, #{item.loginTime,jdbcType=TIMESTAMP}, #{item.status,jdbcType=INTEGER},#{item.phone}
       )
     </foreach>
   </insert>

+ 4 - 3
mec-mall/mall-portal/src/main/java/com/yonge/cooleshow/portal/controller/PaymentController.java

@@ -28,6 +28,7 @@ import org.springframework.web.bind.annotation.RestController;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.validation.Valid;
+import java.math.BigDecimal;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
@@ -102,12 +103,12 @@ public class PaymentController extends BaseController {
                                 orderService.paymentFailedHandle(dataObj.getString("order_no"),notifyMap);
 
                                 break;
-                            case "refund.succeeded" :
+                            case "payment_reverse.succeeded" :
 
                                 orderService.paymentRefundSucceededHandle(dataObj.getString("payment_id")
-                                                ,dataObj.getString("refund_amt"),dataObj.getString("id"),dataObj.getString("fee_amt"));
+                                                , dataObj.getString("reverse_amt"), dataObj.getString("id"), BigDecimal.ZERO.toString());
                                 break;
-                            case "refund.failed" :
+                            case "payment_reverse.failed" :
 
                                 orderService.paymentRefundFailedHandle(dataObj.getString("payment_id")
                                         ,dataObj.getString("error_msg"),dataObj.getString("id"));

+ 12 - 7
mec-mall/mall-portal/src/main/java/com/yonge/cooleshow/portal/service/impl/OmsPortalOrderServiceImpl.java

@@ -8,6 +8,7 @@ import com.github.pagehelper.PageHelper;
 import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.entity.MallCreateOrderModel;
 import com.ym.mec.common.entity.OrderCancelModel;
+import com.ym.mec.common.entity.RefundModel;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.service.IdGeneratorService;
 import com.ym.mec.thirdparty.adapay.Payment;
@@ -817,13 +818,13 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
         String baseUrl = MapUtil.getStr(data,"baseUrl");
         String transNo = MapUtil.getStr(data,"transNo");
         // 金额退回
-        Map<String, Object> refundParams = new HashMap<>(10);
-        refundParams.put("refund_amt", refundAmount);
-        refundParams.put("refund_order_no", orderSn);
-        refundParams.put("notify_url",baseUrl + "/api-mall-portal/payment/callback");
-        refundParams.put("transNo",transNo);
-        HttpResponseResult<BaseResult<Map<String, Object>>> refund = webFeignService.refund(refundParams);
+        RefundModel refundModel = new RefundModel();
+        refundModel.setRefundNo(orderSn);
+        refundModel.setOrderNo(userOrderPayment.getAdapayNo());
+        refundModel.setNotifyUrl(baseUrl + "/api-mall-portal/payment/callback");
+        HttpResponseResult<BaseResult<Map<String, Object>>> refund = webFeignService.refund(refundModel);
         if (!refund.getStatus()) {
+            LOG.error("退款失败:{}",refund.getMsg());
             throw new BizException("退款失败");
         }
         BaseResult<Map<String, Object>> mapBaseResult = refund.getData();
@@ -834,7 +835,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
         userOrderRefund.setPayOrderNo(userOrderPayment.getOrderNo());
         if (mapBaseResult.getStatus()) {
             Map<String,Object> refundBill = mapBaseResult.getData();
-            userOrderRefund.setRefundAmt(new BigDecimal(MapUtil.getStr(refundBill,"refund_amt")));
+            userOrderRefund.setRefundAmt(new BigDecimal(MapUtil.getStr(refundBill,"reversed_amt")));
             userOrderRefund.setStatus(TradeStatusEnum.pending.getCode());
         } else {
             userOrderRefund.setStatus(TradeStatusEnum.failed.getCode());
@@ -933,6 +934,10 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
             return;
         }
         UserOrderRefund userOrderRefund = userOrderRefundMapper.selectByPayTansNo(payTransNo);
+        if (userOrderRefund == null) {
+            LOG.warn("未找到退款订单");
+            return;
+        }
         userOrderRefund.setArrivalTime(new Date());
         userOrderRefund.setStatus(TradeStatusEnum.succeeded.getCode());
         userOrderRefund.setTransNo(refundTransNo);

+ 34 - 1
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/adapay/Payment.java

@@ -6,6 +6,7 @@ import java.util.*;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.huifu.adapay.core.exception.BaseAdaPayException;
+import com.huifu.adapay.model.PaymentReverse;
 import com.huifu.adapay.model.Refund;
 import com.ym.mec.thirdparty.adapay.entity.BaseResult;
 import com.ym.mec.thirdparty.adapay.entity.HfMerchantConfig;
@@ -146,9 +147,41 @@ public class Payment {
 
     public static BaseResult<Map<String ,Object>> refundPayment(Map<String, Object> refundParams) {
 
+        LOGGER.info("退款对象信息:{}",refundParams);
+        String transNo = refundParams.get("transNo").toString();
+        refundParams.remove("transNo");
         Map<String, Object> res;
         try {
-            res = Refund.create(refundParams.get("transNo").toString(), refundParams);
+            res = Refund.create(transNo, refundParams);
+        } catch (BaseAdaPayException e) {
+            return BaseResult.failed(e.getMessage());
+        }
+        if (CollectionUtils.isEmpty(res)) {
+            return BaseResult.failed("请求失败");
+        }
+        LOGGER.info("汇付[支付退款] Resp:{}", res);
+        String errorCode = (String) res.get("error_code");
+        if (null != errorCode) {
+            String errorMsg = (String) res.get("error_msg");
+            return BaseResult.failed(errorMsg);
+        }
+        return BaseResult.succeed(res);
+    }
+
+
+    // 撤销支付
+    public static BaseResult<Map<String ,Object>> reversePayment(String paymentId,String appId,String reverseOrderNo,String reverseAmt,String notifyUrl) {
+
+        LOGGER.info("撤销对象信息:paymentId:{},appId:{},reverseOrderNo:{},reverseAmt:{}",paymentId,appId,reverseOrderNo,reverseAmt);
+        Map<String, Object> res;
+        Map<String,Object> param = new HashMap<>();
+        param.put("app_id",appId);
+        param.put("payment_id",paymentId);
+        param.put("reverse_amt",reverseAmt);
+        param.put("order_no",reverseOrderNo);
+        param.put("notify_url",notifyUrl);
+        try {
+            res = PaymentReverse.create(param);
         } catch (BaseAdaPayException e) {
             return BaseResult.failed(e.getMessage());
         }

+ 5 - 4
mec-web/src/main/java/com/ym/mec/web/controller/APIController.java

@@ -7,6 +7,7 @@ import com.ym.mec.biz.service.*;
 import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.entity.MallCreateOrderModel;
 import com.ym.mec.common.entity.OrderCancelModel;
+import com.ym.mec.common.entity.RefundModel;
 import com.ym.mec.thirdparty.adapay.Payment;
 import com.ym.mec.thirdparty.adapay.entity.BaseResult;
 import io.swagger.annotations.Api;
@@ -215,13 +216,13 @@ public class APIController extends BaseController {
 
 
 
-	// 商城获取 退款数据
-	@GetMapping("/refund")
-	public HttpResponseResult<BaseResult<Map<String, Object>>> refund(@RequestParam Map<String,Object> refundInfo) {
+	// 商城获取 退款数据  只能全额退款
+	@PostMapping("/refund")
+	public HttpResponseResult<BaseResult<Map<String, Object>>> refund(@RequestBody RefundModel refundModel) {
 
 		try {
+			BaseResult<Map<String, Object>> mapBaseResult = studentPaymentOrderService.refund(refundModel.getOrderNo(),refundModel.getNotifyUrl(),refundModel.getRefundNo());
 
-			BaseResult<Map<String, Object>> mapBaseResult = Payment.refundPayment(refundInfo);
 			return succeed(mapBaseResult);
 		} catch (Exception e) {
 			e.printStackTrace();