zhouxiang
2021-12-10 4c6f331bd95de528b543f13454650f9fbfd6d12c
兼容导医创建订单操作人
2个文件已添加
2个文件已修改
213 ■■■■ 已修改文件
phi_platform_user/src/main/java/com/hx/phip/order/controller/OrderController.java 37 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/order/service/impl/OrderServiceImpl.java 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/service/EmployeeService.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/service/impl/EmployeeServiceImpl.java 101 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/order/controller/OrderController.java
@@ -15,6 +15,7 @@
import com.hx.phip.order.service.OrderService;
import com.hx.phip.service.SysAdminService;
import com.hx.phip.tool.CreateNo;
import com.hx.resultTool.Result;
import com.hx.util.StringUtils;
import com.platform.constants.LoginConstant;
import com.platform.entity.ThirtApplication;
@@ -46,7 +47,7 @@
     * 创建订单
     */
    @RequestMapping(value = "/add",method = RequestMethod.POST)
    public void orderAdd(HttpServletRequest request, @RequestBody String param) {
    public Result orderAdd(HttpServletRequest request, @RequestBody String param) {
        if(StringUtils.isEmpty(param)){
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"请传订单参数");
@@ -74,6 +75,7 @@
        String shopId = object.getString("shopId");//操作人的门店id
        orderService.add(orderTotal,orderItem,type,orderDeveloperList,operatorId,shopId);
        return Result.success();
    }
    /**
@@ -81,7 +83,7 @@
     * @param param
     */
    @RequestMapping(value = "/pay",method = RequestMethod.POST)
    public void orderPay(@RequestBody String param) throws Exception {
    public Result orderPay(@RequestBody String param) throws Exception {
        if(StringUtils.isEmpty(param)){
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"请传订单参数");
        }
@@ -107,6 +109,7 @@
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"请传用户操作人标识");
        }
        orderService.orderPay(type,orderId,total,amountList,operatorId);
        return Result.success();
    }
    /**
     * 测试充值储值金
@@ -144,9 +147,9 @@
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"订单类型为空");
        }
        if(StringUtils.isEmpty(orderTotal.getAppId())){
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"来源应用appId为空");
        }
//        if(StringUtils.isEmpty(orderTotal.getAppId())){
//            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"来源应用appId为空");
//        }
        if(StringUtils.isEmpty(orderTotal.getSourceName())){
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"订单来源名称为空");
        }
@@ -156,18 +159,18 @@
//        if(StringUtils.isEmpty(orderTotal.getChannelType())){
//            throwParamException("渠道类型不能为空");
//        }
        if(StringUtils.isEmpty(orderTotal.getCommonId())){
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"渠道标识不能为空");
        }
        if(StringUtils.isEmpty(orderTotal.getCommonName())){
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"渠道名称不能为空");
        }
        if(StringUtils.isEmpty(orderTotal.getDepartmentCode())){
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"科室编码不能为空");
        }
        if(StringUtils.isEmpty(orderTotal.getDepartmentName())){
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"科室名称不能为空");
        }
//        if(StringUtils.isEmpty(orderTotal.getCommonId())){
//            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"渠道标识不能为空");
//        }
//        if(StringUtils.isEmpty(orderTotal.getCommonName())){
//            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"渠道名称不能为空");
//        }
//        if(StringUtils.isEmpty(orderTotal.getDepartmentCode())){
//            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"科室编码不能为空");
//        }
//        if(StringUtils.isEmpty(orderTotal.getDepartmentName())){
//            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"科室名称不能为空");
//        }
        return orderTotal;
    }
phi_platform_user/src/main/java/com/hx/phip/order/service/impl/OrderServiceImpl.java
@@ -39,8 +39,6 @@
    @Resource
    private UserService userService;
    @Resource
    private EmployeeRoleService employeeRoleService;
    @Resource
    private OrderDeveloperService orderDeveloperService;
    @Resource
    private SysAdminService sysAdminService;
@@ -62,12 +60,18 @@
    private OrderLogService orderLogService;
    @Resource
    private OrderGoodsSpecsService orderGoodsSpecsService;
    @Resource
    private EmployeeService employeeService;
    @Override
    public void add(OrdersTotal ordersTotal, List<OrderItem> items, Integer type, List<OrderDeveloper> orderDeveloperList,String operatorId,String shopId) {
        SysAdmin sysAdmin = sysAdminService.selectOneByKey(operatorId);
        if(sysAdmin==null){
        Employee employee = employeeService.selectOneByKey(operatorId);
        if(sysAdmin==null && employee==null){
            throw new PlatTipsException(PlatformCode.ERROR_TIPS,"未找到操作人的信息"+operatorId);
        }
        operatorId=sysAdmin==null?employee.getId():sysAdmin.getId();
        String operatorName=sysAdmin==null?employee.getCnName():sysAdmin.getName();
        Integer operatorType=sysAdmin==null?1:0;
        Shop shop = shopService.selectOneByKey(shopId);//查询门店,创建订单人的门店
        if(shop==null){
            throw new PlatTipsException(PlatformCode.ERROR_TIPS,"未找到门店信息"+shopId);
@@ -187,11 +191,11 @@
        }
        setOrderTotal(ordersTotal, sysAdmin, shop, totalPrice, shouldOrderTotal, discountTotal);
        setOrderTotal(ordersTotal, shop, totalPrice, shouldOrderTotal, discountTotal,operatorId,operatorName,operatorType);
        //创建总订单
        ordersTotalService.insert(ordersTotal);
        orderLogService.insert(setCreateOrderTotalUserLog(ordersTotal,sysAdmin.getName(),sysAdmin.getId()));
        orderLogService.insert(setCreateOrderTotalUserLog(ordersTotal,operatorId,operatorName));
        //总订单绑定开发人
        if(orderDeveloperList !=null && orderDeveloperList.size()>0){
@@ -237,12 +241,12 @@
        orderGoodsSpecs.setUnit(object.getString("unit"));
    }
    private void setOrderTotal(OrdersTotal ordersTotal, SysAdmin sysAdmin, Shop shop, BigDecimal totalPrice, BigDecimal shouldOrderTotal, BigDecimal discountTotal) {
    private void setOrderTotal(OrdersTotal ordersTotal,  Shop shop, BigDecimal totalPrice, BigDecimal shouldOrderTotal, BigDecimal discountTotal,String operatorId,String operatorName,Integer  operatorType) {
        String orderNum = CreateNo.createTimeNo(systemParameterMapper, "S", 4, "yyyyMMdd");
        ordersTotal.setOrderNo(orderNum);//订单编号
        ordersTotal.setOperatorType(sysAdmin.getType());//操作类型(0:系统管理员,1:员工)
        ordersTotal.setOperatorId(sysAdmin.getId());//下单操作人标识
        ordersTotal.setOperatorName(sysAdmin.getName());//下单操作人名称
        ordersTotal.setOperatorType(operatorType);//操作类型(0:系统管理员,1:员工)
        ordersTotal.setOperatorId(operatorId);//下单操作人标识
        ordersTotal.setOperatorName(operatorName);//下单操作人名称
        ordersTotal.setPayTotal(BigDecimal.ZERO);//支付现金金额
        ordersTotal.setPayRecharge(BigDecimal.ZERO);//支付储值金金额
        ordersTotal.setPayIncrement(BigDecimal.ZERO);//支付增值金金额
@@ -258,9 +262,13 @@
    @Override
    public void orderPay(Integer type, String orderId, String total, JSONArray amountList,String operatorId) throws Exception {
        SysAdmin sysAdmin = sysAdminService.selectOneByKey(operatorId);
        if(sysAdmin==null){
        Employee employee = employeeService.selectOneByKey(operatorId);
        if(sysAdmin==null && employee==null){
            throw new PlatTipsException(PlatformCode.ERROR_TIPS,"未找到操作人的信息"+operatorId);
        }
        operatorId=sysAdmin==null?employee.getId():sysAdmin.getId();
        String operatorName=sysAdmin==null?employee.getCnName():sysAdmin.getName();
        OrdersTotal ordersTotal = ordersTotalService.selectOneByKey(orderId);
        if(ordersTotal==null ){
            throw new PlatTipsException(PlatformCode.ERROR_TIPS,"订单不存在");
@@ -311,7 +319,7 @@
                userMoney.setValueAddedFund(valueAddedFund);
                //记录储值金用户资金变动日志
                setUserLog(sysAdmin, ordersTotal.getUserId(), money, valueAddedFundBig, userMoneyLog, leftMoney,UserMoneyLog.TYPE_VALUE_ADDED_FUND,UserMoneyLog.OP_TYPE_REDUCE);
                setUserLog(operatorId,operatorName, ordersTotal.getUserId(), money, valueAddedFundBig, userMoneyLog, leftMoney,UserMoneyLog.TYPE_VALUE_ADDED_FUND,UserMoneyLog.OP_TYPE_REDUCE);
                userMoneyLogService.insert(userMoneyLog);
                payIncrement=payIncrement.add(money);//累加增值金
                System.out.println("变化后的增值金:"+SimpleEncrypt.simpleDeCode(userMoney.getValueAddedFund()));
@@ -329,7 +337,7 @@
                BigDecimal leftMoney = storedValueFundBig.subtract(money);//支付完成的增值金额
                userMoney.setStoredValueFund(SimpleEncrypt.simpleEnCode(leftMoney.toString()));//支付完成后剩下的储值金
                //记录储值金用户资金变动日志
                setUserLog(sysAdmin, ordersTotal.getUserId(), money, storedValueFundBig, userMoneyLog, leftMoney,UserMoneyLog.TYPE_STORED_VALUE_FUND,UserMoneyLog.OP_TYPE_REDUCE);
                setUserLog(operatorId,operatorName, ordersTotal.getUserId(), money, storedValueFundBig, userMoneyLog, leftMoney,UserMoneyLog.TYPE_STORED_VALUE_FUND,UserMoneyLog.OP_TYPE_REDUCE);
                userMoneyLogService.insert(userMoneyLog);
                payRecharge=payRecharge.add(money);//累加储值金
                System.out.println("变化后的储值金:"+SimpleEncrypt.simpleDeCode(userMoney.getStoredValueFund()));
@@ -355,7 +363,7 @@
        }
        ordersTotalService.updatePay(ordersTotal);//更新总订单
        orderLogService.insert(setPayOrderTotalUserLog(ordersTotal,sysAdmin.getName(),sysAdmin.getId()));//记录日志
        orderLogService.insert(setPayOrderTotalUserLog(ordersTotal,operatorName,operatorId));//记录日志
        //获取子订单
        List<OrderItem> orderItemList= orderItemService.selectItemList(ordersTotal.getId());
@@ -463,19 +471,19 @@
        userProject.setUserId(ordersTotal.getUserId());
    }
    private void setUserLog(SysAdmin sysAdmin, String userId, BigDecimal money, BigDecimal valueAddedFundBig, UserMoneyLog userMoneyLog, BigDecimal leftMoney,Integer type,Integer opType) {
    private void setUserLog(String operatorId,String operatorName, String userId, BigDecimal money, BigDecimal valueAddedFundBig, UserMoneyLog userMoneyLog, BigDecimal leftMoney,Integer type,Integer opType) {
        userMoneyLog.setUserId(userId);
        userMoneyLog.setType(type);
        userMoneyLog.setOpNumber(money);
        userMoneyLog.setOpBeforeNumber(valueAddedFundBig);
        userMoneyLog.setOpAfterNumber(leftMoney);
        userMoneyLog.setOpAdminId(sysAdmin.getId());
        userMoneyLog.setOpAdminName(sysAdmin.getName());
        userMoneyLog.setOpAdminId(operatorId);
        userMoneyLog.setOpAdminName(operatorName);
        userMoneyLog.setRemarks("");
        userMoneyLog.setOpType(opType);
    }
    private OrderLog setCreateOrderTotalUserLog(OrdersTotal ordersTotal,String opName,String opId){
    private OrderLog setCreateOrderTotalUserLog(OrdersTotal ordersTotal,String opId,String opName){
        return new OrderLog(ordersTotal.getId(),OrderLogConstants.LOG_TYPE_CREATE,"操作人:"+opName+",创建订单类型:"+ordersTotal.getType()+",订单编号:"+ordersTotal.getOrderNo()
                    +",应付总金额:"+ordersTotal.getShouldTotal(),opName,opId,ordersTotal.getStatus());
    }
phi_platform_user/src/main/java/com/hx/phip/service/EmployeeService.java
New file
@@ -0,0 +1,33 @@
package com.hx.phip.service;
import com.hx.phiappt.model.Employee;
import com.hx.mybatisTool.SqlSentence;
import java.util.List;
import java.util.Map;
public interface EmployeeService {
    int selectCount(SqlSentence sqlSentence);
    void insert(Employee employee);
    List<Employee> selectList(SqlSentence sqlSentence);
    List<Map<String,Object>> selectListMap(SqlSentence sqlSentence);
    Employee selectOne(SqlSentence sqlSentence);
    Map<String,Object> selectOneMap(SqlSentence sqlSentence);
    Employee selectOneByKey(Object object);
    Employee selectOneByKeyBlob(Object object);
    void updateAll(Employee employee);
    void updateWhere(SqlSentence sqlSentence);
    void deleteOne(String delId);
}
phi_platform_user/src/main/java/com/hx/phip/service/impl/EmployeeServiceImpl.java
New file
@@ -0,0 +1,101 @@
package com.hx.phip.service.impl;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.hx.exception.TipsException;
import com.hx.phip.dao.mapper.EmployeeMapper;
import com.hx.phiappt.model.Employee;
import com.hx.phip.service.EmployeeService;
import com.hx.mybatisTool.SqlSentence;
import java.util.List;
import java.util.Map;
@Transactional
@Service
public class EmployeeServiceImpl implements EmployeeService {
    @Resource
    private EmployeeMapper employeeMapper;
    /**查询列表*/
    @Override
    public List<Employee> selectList(SqlSentence sqlSentence) {
        return employeeMapper.selectList(sqlSentence);
    }
    /**查询列表*/
    @Override
    public List<Map<String,Object>> selectListMap(SqlSentence sqlSentence) {
        return employeeMapper.selectListMap(sqlSentence);
    }
    /**查询单个*/
    @Override
    public Employee selectOne(SqlSentence sqlSentence) {
        return employeeMapper.selectOne(sqlSentence);
    }
    /**查询单个*/
    @Override
    public Map<String,Object> selectOneMap(SqlSentence sqlSentence) {
        return employeeMapper.selectOneMap(sqlSentence);
    }
    /**查询单个,大数据不拿取*/
    @Override
    public Employee selectOneByKey(Object object) {
        return employeeMapper.selectOneByKey(object);
    }
    /**查询单个,大数据拿取*/
    @Override
    public Employee selectOneByKeyBlob(Object object) {
        return employeeMapper.selectOneByKeyBlob(object);
    }
    /**新增*/
    @Override
    public void insert(Employee employee) {
        int count = employeeMapper.insert(employee);
        if(count != 1) {
            throw new TipsException("新增失败!");
        }
    }
    /**修改*/
    @Override
    public void updateAll(Employee employee) {
        int count = employeeMapper.updateAll(employee);
        if(count!=1) {
            throw new TipsException("保存失败!");
        }
    }
    /**修改*/
    @Override
    public void updateWhere(SqlSentence sqlSentence) {
        int count = employeeMapper.updateWhere(sqlSentence);
        if(count!=1) {
            throw new TipsException("保存失败!");
        }
    }
    /**删除一个*/
    @Override
    public void deleteOne(String delId) {
        int count = employeeMapper.deleteById(delId);
        if(count!=1) {
            throw new TipsException("删除失败!");
        }
    }
    /**查询条数*/
    @Override
    public int selectCount(SqlSentence sqlSentence) {
        int count = employeeMapper.selectCount(sqlSentence);
        return count;
    }
}