zhouxiang
2021-12-10 0ec4f7daa734223d405e673bc838830a7782c0b5
修改创建订单和结账
7个文件已添加
5个文件已修改
287 ■■■■■ 已修改文件
phi_platform_common/src/main/java/com/hx/phip/dao/mapper/OrdersTotalMapper.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_common/src/main/resources/mapper/OrdersTotalMapper.xml 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/order/controller/OrderController.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/order/service/impl/OrderServiceImpl.java 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/service/PaymentMethodService.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/service/PaymentMethodTypeService.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/service/ShopService.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/service/UserMoneyLogService.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/service/UserMoneyService.java 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/service/UserProjectItemService.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/service/UserProjectService.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/service/impl/OrdersTotalServiceImpl.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_common/src/main/java/com/hx/phip/dao/mapper/OrdersTotalMapper.java
@@ -35,7 +35,9 @@
    int deleteWhere(SqlSentence sqlSentence);
    /**删除,返回删除数量*/
    int deleteById(Object object);
    /*更新总订单 支付信息*/
    void updatePay(@Param("payRecharge")BigDecimal payRecharge,@Param("payIncrement") BigDecimal payIncrement,
                   @Param("payTotal") BigDecimal payTotal,@Param("status") Integer status, @Param("id")String id,@Param("payTime") Date payTime);
                   @Param("payTotal") BigDecimal payTotal,@Param("status") Integer status, @Param("id")String id,@Param("payTime") Date payTime,
                   @Param("payStatus") Integer payStatus);
}
phi_platform_common/src/main/resources/mapper/OrdersTotalMapper.xml
@@ -83,6 +83,9 @@
        delete from orders_total WHERE id = #{value}
    </delete>
    
    <update id="updatePay">
        update
            orders_total
phi_platform_user/src/main/java/com/hx/phip/order/controller/OrderController.java
@@ -26,6 +26,7 @@
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.List;
@@ -45,12 +46,12 @@
     * 创建订单
     */
    @RequestMapping(value = "/add",method = RequestMethod.POST)
    public void orderAdd(@RequestBody String param) {
    public void orderAdd(HttpServletRequest request, @RequestBody String param) {
        if(StringUtils.isEmpty(param)){
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"请传订单参数");
        }
        ThirtApplication thirtApplication= (ThirtApplication) getRequestAttribute(LoginConstant.LOGIN_APPLY);
        ThirtApplication thirtApplication= (ThirtApplication) request.getSession().getAttribute(LoginConstant.LOGIN_APPLY);
        JSONObject object = JSONObject.parseObject(param);
        //获取总订单对象
phi_platform_user/src/main/java/com/hx/phip/order/service/impl/OrderServiceImpl.java
@@ -87,6 +87,7 @@
        List<String> packageIds=new ArrayList<>();//用来装套餐或者卡项的id(标识)
        JSONArray jsonObject = new JSONArray();//用来封装规格json集合
        Map<String,Object> map=new HashMap<>();//用来存储规格的map
        BigDecimal discountTotal=BigDecimal.ZERO;//总订单的优惠总金额
        //计算总订单金额信息,填补子订单信息
        for(OrderItem vo:items){
@@ -107,8 +108,13 @@
                }
                //项目实付金额=项目的销售价格*购买数量*折扣
                 actualTotal = project.getPrice().multiply(buyNum).multiply(vo.getDiscount().divide(new BigDecimal(100)));
                //项目订单总额=项目原价*购买数量,如果项目没有原价就用现价
                sonTotalPrice=sonTotalPrice.add(project.getOriginalPrice()==null?project.getPrice().multiply(buyNum):project.getOriginalPrice().multiply(buyNum));
                //优惠金额=项目的销售单价*数量-用户实付金额;
                discountTotal=discountTotal.add(project.getPrice().multiply(buyNum).subtract(actualTotal));
                vo.setSingle(project.getTreatmentItemsNum()==null?1:project.getTreatmentItemsNum());//单次疗程数量
                vo.setUsedTotal(vo.getSingle()*vo.getBuyNum()); //总次疗程次数,单次疗程次数*购买的总量
                vo.setOriPrice(project.getOriginalPrice());//原价,项目的原价
@@ -131,8 +137,12 @@
                }
                //商品实付金额=商品的销售价格*购买数量*折扣
                actualTotal = consumables.getPrice().multiply(buyNum).multiply(vo.getDiscount().divide(new BigDecimal(100)));
                //商品订单总额=项目销售价*购买数量
                sonTotalPrice=sonTotalPrice.add(consumables.getPrice().multiply(buyNum));
                //优惠金额=商品的销售单价*数量-用户实付金额;
                discountTotal=discountTotal.add(consumables.getPrice().multiply(buyNum).subtract(actualTotal));
                vo.setSingle(0);//单次疗程数量
                vo.setUsedTotal(vo.getSingle()*vo.getBuyNum());//总次疗程次数,单次疗程次数*购买的总量
@@ -186,10 +196,11 @@
        ordersTotal.setPayIncrement(BigDecimal.ZERO);//支付增值金金额
        ordersTotal.setTotal(totalPrice);//订单总金额
        ordersTotal.setShouldTotal(shouldOrderTotal);//订单应付支付总金额
        ordersTotal.setDiscountTotal(totalPrice.subtract(shouldOrderTotal));//优惠金额,以元为存储
        ordersTotal.setDiscountTotal(discountTotal);//优惠金额,以元为存储
        ordersTotal.setShopId(shop.getId());//操作人门店标识
        ordersTotal.setShopName(shop.getName());//操作人门店名称
        ordersTotal.setActualTotal(BigDecimal.ZERO);//用户实际支付的总金额
        ordersTotal.setChannelType(OrderTotalConstants.CHANNEL_TYPE_NOTHING);//暂定用没有渠道类型
        //创建总订单
        ordersTotalService.insert(ordersTotal);
@@ -230,6 +241,8 @@
            throw new PlatTipsException(PlatformCode.ERROR_TIPS,"后台应付金额和传进参数不符合请检查");
        }
        UserMoney userMoney=userMoneyService.selectUserId(ordersTotal.getUserId());
        System.out.println("变化前的增值金:"+SimpleEncrypt.simpleDeCode(userMoney.getValueAddedFund()));
        System.out.println("变化前的储值金:"+SimpleEncrypt.simpleDeCode(userMoney.getStoredValueFund()));
        BigDecimal money = null;//用户真实支付的金额
        BigDecimal valueAddedFundBig = null;//增值金,用来转换类型
@@ -273,6 +286,8 @@
                setUserLog(sysAdmin, 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()));
                userMoneyService.updateValueAddedFund(userMoney);//更改用户的增值金
            }else if(paymentMethodType.getName().equals("储值金") && paymentMethod.getUsedCashier()==1){
                isAccount=2;
                if(userMoney==null){
@@ -284,20 +299,17 @@
                    throw new PlatTipsException(PlatformCode.ERROR_TIPS,"用户的储值金不足");
                }
                BigDecimal leftMoney = storedValueFundBig.subtract(money);//支付完成的增值金额
                storedValueFund = SimpleEncrypt.simpleEnCode(leftMoney.toString());//剩下之后并且加密的增值金
                userMoney.setValueAddedFund(storedValueFund);
                userMoney.setStoredValueFund(SimpleEncrypt.simpleEnCode(leftMoney.toString()));//支付完成后剩下的储值金
                //记录储值金用户资金变动日志
                setUserLog(sysAdmin, 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()));
                userMoneyService.updateStoredValueFund(userMoney);//更改用户的储值金
            }
        }
        if(isAccount==0){
            throw new PlatTipsException(PlatformCode.ERROR_TIPS,"请传支付方式编码");
        }else if(isAccount<=1){
            userMoneyService.updateValueAddedFund(userMoney);
        }else if(isAccount>=1 && isAccount <=2){
            userMoneyService.updateStoredValueFund(userMoney);
        }
        //获取子订单
        List<OrderItem> orderItemList= orderItemService.selectItemList(ordersTotal.getId());
@@ -312,8 +324,8 @@
            date = new Date();
            userProject=new UserProject();
            userProjectItem = new UserProjectItem();
            if(vo.getType().equals(OrderItemConstants.TYPE_PROJECT) && vo.getType().equals(OrderItemConstants.TYPE_RETAIL)){
                setUserProject(ordersTotal, userProject, vo,vo.getType());
            if(vo.getType().equals(OrderItemConstants.TYPE_PROJECT)){
                setUserProject(ordersTotal, userProject, vo);
                userProjectService.insert(userProject);//新增用户项目记录
                setUserProjectItem(ordersTotal, userProject, userProjectItem, date, vo);
@@ -404,8 +416,8 @@
        userProjectItem.setUserId(ordersTotal.getUserId());//用户id
    }
    private void setUserProject(OrdersTotal ordersTotal, UserProject userProject, OrderItem vo,String type) {
        userProject.setType(type);
    private void setUserProject(OrdersTotal ordersTotal, UserProject userProject, OrderItem vo) {
        userProject.setType(vo.getType());
        userProject.setGoodsNo(vo.getGoodsNo());
        userProject.setGoodsId(vo.getCommonId());
        userProject.setEffectiveStatus(UserProjectConstants.EFF_STATUS_YES);
phi_platform_user/src/main/java/com/hx/phip/service/PaymentMethodService.java
New file
@@ -0,0 +1,33 @@
package com.hx.phip.service;
import com.hx.phiappt.model.PaymentMethod;
import com.hx.mybatisTool.SqlSentence;
import java.util.List;
import java.util.Map;
public interface PaymentMethodService {
    int selectCount(SqlSentence sqlSentence);
    void insert(PaymentMethod paymentMethod);
    List<PaymentMethod> selectList(SqlSentence sqlSentence);
    List<Map<String,Object>> selectListMap(SqlSentence sqlSentence);
    PaymentMethod selectOne(SqlSentence sqlSentence);
    Map<String,Object> selectOneMap(SqlSentence sqlSentence);
    PaymentMethod selectOneByKey(Object object);
    PaymentMethod selectOneByKeyBlob(Object object);
    void updateAll(PaymentMethod paymentMethod);
    void updateWhere(SqlSentence sqlSentence);
    void deleteOne(String delId);
    /*根据支付方式编码查询支付方式信息*/
    PaymentMethod selectNumberNo(String method);
}
phi_platform_user/src/main/java/com/hx/phip/service/PaymentMethodTypeService.java
New file
@@ -0,0 +1,32 @@
package com.hx.phip.service;
import com.hx.phiappt.model.PaymentMethodType;
import com.hx.mybatisTool.SqlSentence;
import java.util.List;
import java.util.Map;
public interface PaymentMethodTypeService {
    int selectCount(SqlSentence sqlSentence);
    void insert(PaymentMethodType paymentMethodType);
    List<PaymentMethodType> selectList(SqlSentence sqlSentence);
    List<Map<String,Object>> selectListMap(SqlSentence sqlSentence);
    PaymentMethodType selectOne(SqlSentence sqlSentence);
    Map<String,Object> selectOneMap(SqlSentence sqlSentence);
    PaymentMethodType selectOneByKey(Object object);
    PaymentMethodType selectOneByKeyBlob(Object object);
    void updateAll(PaymentMethodType paymentMethodType);
    void updateWhere(SqlSentence sqlSentence);
    void deleteOne(String delId);
}
phi_platform_user/src/main/java/com/hx/phip/service/ShopService.java
New file
@@ -0,0 +1,33 @@
package com.hx.phip.service;
import com.hx.phiappt.model.Shop;
import com.hx.mybatisTool.SqlSentence;
import java.util.List;
import java.util.Map;
public interface ShopService {
    int selectCount(SqlSentence sqlSentence);
    void insert(Shop shop);
    List<Shop> selectList(SqlSentence sqlSentence);
    List<Map<String,Object>> selectListMap(SqlSentence sqlSentence);
    Shop selectOne(SqlSentence sqlSentence);
    Map<String,Object> selectOneMap(SqlSentence sqlSentence);
    Shop selectOneByKey(Object object);
    Shop selectOneByKeyBlob(Object object);
    void updateAll(Shop shop);
    void updateWhere(SqlSentence sqlSentence);
    void deleteOne(String delId);
}
phi_platform_user/src/main/java/com/hx/phip/service/UserMoneyLogService.java
New file
@@ -0,0 +1,33 @@
package com.hx.phip.service;
import com.hx.phiappt.model.UserMoneyLog;
import com.hx.mybatisTool.SqlSentence;
import java.util.List;
import java.util.Map;
public interface UserMoneyLogService {
    int selectCount(SqlSentence sqlSentence);
    void insert(UserMoneyLog userMoneyLog);
    List<UserMoneyLog> selectList(SqlSentence sqlSentence);
    List<Map<String,Object>> selectListMap(SqlSentence sqlSentence);
    UserMoneyLog selectOne(SqlSentence sqlSentence);
    Map<String,Object> selectOneMap(SqlSentence sqlSentence);
    UserMoneyLog selectOneByKey(Object object);
    UserMoneyLog selectOneByKeyBlob(Object object);
    void updateAll(UserMoneyLog userMoneyLog);
    void updateWhere(SqlSentence sqlSentence);
    void deleteOne(String delId);
}
phi_platform_user/src/main/java/com/hx/phip/service/UserMoneyService.java
New file
@@ -0,0 +1,42 @@
package com.hx.phip.service;
import com.hx.phiappt.model.UserMoney;
import com.hx.mybatisTool.SqlSentence;
import java.util.List;
import java.util.Map;
public interface UserMoneyService {
    int selectCount(SqlSentence sqlSentence);
    void insert(UserMoney userMoney);
    List<UserMoney> selectList(SqlSentence sqlSentence);
    List<Map<String,Object>> selectListMap(SqlSentence sqlSentence);
    UserMoney selectOne(SqlSentence sqlSentence);
    Map<String,Object> selectOneMap(SqlSentence sqlSentence);
    UserMoney selectOneByKey(Object object);
    UserMoney selectOneByKeyBlob(Object object);
    void updateAll(UserMoney userMoney);
    void updateWhere(SqlSentence sqlSentence);
    void deleteOne(String delId);
    /*根据用户id查询用户的资金信息*/
    UserMoney selectUserId(String userId);
    /**
     * 跟新用户的储值金
     * @param userMoney
     */
    void updateStoredValueFund(UserMoney userMoney);
    /*更新用户的增值金额*/
    void updateValueAddedFund(UserMoney userMoney);
}
phi_platform_user/src/main/java/com/hx/phip/service/UserProjectItemService.java
New file
@@ -0,0 +1,33 @@
package com.hx.phip.service;
import com.hx.phiappt.model.user.UserProjectItem;
import com.hx.mybatisTool.SqlSentence;
import java.util.List;
import java.util.Map;
public interface UserProjectItemService {
    int selectCount(SqlSentence sqlSentence);
    void insert(UserProjectItem userProjectItem);
    List<UserProjectItem> selectList(SqlSentence sqlSentence);
    List<Map<String,Object>> selectListMap(SqlSentence sqlSentence);
    UserProjectItem selectOne(SqlSentence sqlSentence);
    Map<String,Object> selectOneMap(SqlSentence sqlSentence);
    UserProjectItem selectOneByKey(Object object);
    UserProjectItem selectOneByKeyBlob(Object object);
    void updateAll(UserProjectItem userProjectItem);
    void updateWhere(SqlSentence sqlSentence);
    void deleteOne(String delId);
}
phi_platform_user/src/main/java/com/hx/phip/service/UserProjectService.java
New file
@@ -0,0 +1,33 @@
package com.hx.phip.service;
import com.hx.phiappt.model.user.UserProject;
import com.hx.mybatisTool.SqlSentence;
import java.util.List;
import java.util.Map;
public interface UserProjectService {
    int selectCount(SqlSentence sqlSentence);
    void insert(UserProject userProject);
    List<UserProject> selectList(SqlSentence sqlSentence);
    List<Map<String,Object>> selectListMap(SqlSentence sqlSentence);
    UserProject selectOne(SqlSentence sqlSentence);
    Map<String,Object> selectOneMap(SqlSentence sqlSentence);
    UserProject selectOneByKey(Object object);
    UserProject selectOneByKeyBlob(Object object);
    void updateAll(UserProject userProject);
    void updateWhere(SqlSentence sqlSentence);
    void deleteOne(String delId);
}
phi_platform_user/src/main/java/com/hx/phip/service/impl/OrdersTotalServiceImpl.java
@@ -94,7 +94,7 @@
    @Override
    public void updatePay(OrdersTotal ordersTotal) {
        ordersTotalMapper.updatePay(ordersTotal.getPayRecharge(),ordersTotal.getPayIncrement(),ordersTotal.getPayTotal(),ordersTotal.getStatus(),ordersTotal.getId(),ordersTotal.getPayTime());
        ordersTotalMapper.updatePay(ordersTotal.getPayRecharge(),ordersTotal.getPayIncrement(),ordersTotal.getPayTotal(),ordersTotal.getStatus(),ordersTotal.getId(),ordersTotal.getPayTime(),ordersTotal.getPayStatus());
    }
    /**查询条数*/