935090232@qq.com
2022-02-22 bbe0a2fd03063316e50cf141986bda984599bbda
zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxRefundRecordAction.java
@@ -1,7 +1,5 @@
package com.matrix.system.shopXcx.api.action;
import com.matrix.biz.bean.BizUser;
import com.matrix.component.redis.RedisUserLoginUtils;
import com.matrix.component.tools.WxUtils;
import com.matrix.core.pojo.AjaxResult;
import com.matrix.core.tools.LogUtil;
@@ -9,6 +7,8 @@
import com.matrix.system.common.constance.AppConstance;
import com.matrix.system.common.dao.BusParameterSettingsDao;
import com.matrix.system.common.dao.CustomerDataDictionaryDao;
import com.matrix.system.common.init.UserCacheManager;
import com.matrix.system.hive.bean.SysVipInfo;
import com.matrix.system.shopXcx.api.service.WxShopRefundRecordService;
import com.matrix.system.shopXcx.api.tools.SMSTools;
import com.matrix.system.shopXcx.bean.ShopDeliveryInfo;
@@ -38,7 +38,7 @@
@RequestMapping(value = "wxapi/RefundRecord")
public class WxRefundRecordAction {
    @Autowired
    private RedisUserLoginUtils redisUserLoginUtils;
    private UserCacheManager userCacheManager;
    @Autowired
    private ShopRefundRecordDao refundRecordDao;
    @Autowired
@@ -103,6 +103,7 @@
        return Double.valueOf(moneyStr);
    }
    /**
     * 接收保存退款退货数据
     */
@@ -110,10 +111,10 @@
    @PostMapping(value = "/saveRefundRecord")
    public @ResponseBody
    AjaxResult saveRefundRecord(@RequestBody ShopRefundRecord refundRecord) {
        BizUser loginUser = redisUserLoginUtils.getLoginUser(BizUser.class);
        SysVipInfo loginUser = userCacheManager.getLoginUser();
        refundRecord.setCreateBy(loginUser.getOpenId());
        refundRecord.setUpdateBy(loginUser.getOpenId());
        refundRecord.setUserId(loginUser.getOpenId());
        refundRecord.setUserId(loginUser.getId());
        refundRecord.setCompanyId(loginUser.getCompanyId());
        refundRecord.setAuditStatus(AppConstance.REFUND_NOT_AUDITED);
        refundRecord.setRefundStatus(AppConstance.REFUND_PROCESSING);
@@ -124,7 +125,7 @@
        refundRecord.setApplyTime(new Date());
        ShopRefundRecord record = new ShopRefundRecord();
        record.setUserId(loginUser.getOpenId());
        record.setUserId(loginUser.getId());
        record.setOrderId(refundRecord.getOrderId());
        List<ShopRefundRecord> shopRefundRecords = refundRecordDao.selectByModel(record);
        if(CollectionUtils.isNotEmpty(shopRefundRecords)){
@@ -135,13 +136,13 @@
            if (i == 0) {
                return new AjaxResult(AjaxResult.STATUS_FAIL, "保存失败");
            }
            ShopOrder order = shopOrderDao.selectById(refundRecord.getOrderId());
            //未发货的订单取消订单不走后台审核直接退款
            List<ShopRefundRecord> refundRecordsList = refundRecordDao.selectByModel(record);
            if(CollectionUtils.isNotEmpty(refundRecordsList)){
                ShopRefundRecord shopRecord = refundRecordsList.get(0);
                Integer orderId = shopRecord.getOrderId();
                ShopOrder order = shopOrderDao.selectById(orderId);
                if (order == null) {
                    return new AjaxResult(AjaxResult.STATUS_FAIL, "未发货直接退款未找到订单信息");
                }
@@ -159,8 +160,11 @@
                    if(flag){
                        ShopRefundRecord fundRecord = refundRecordDao.selectById(shopRecord.getId());
                        refundRecordService.sendRefundInfoToUser(fundRecord);
                        refundRecordService.updateGroupBuyStatus(orderId.longValue());
                        return new AjaxResult(AjaxResult.STATUS_SUCCESS, "退款成功");
                    }
                    return new AjaxResult(AjaxResult.STATUS_FAIL, "退款失败");
@@ -173,6 +177,8 @@
            modifyMap.put("id", orderId);
            modifyMap.put("orderStatus", ShopOrder.ORDER_STATUS_APPLY_MONEYBACK);
            shopOrderDao.updateByMap(modifyMap);
            return new AjaxResult(AjaxResult.STATUS_SUCCESS, "保存成功");
        }
@@ -186,9 +192,8 @@
    @PostMapping("/findRefundRecord")
    @ResponseBody
    public AjaxResult getRefundRecordByUserId(@RequestBody ShopRefundRecord refundRecord) {
        BizUser loginUser = redisUserLoginUtils.getLoginUser(BizUser.class);
        String userId = loginUser.getOpenId();
        refundRecord.setUserId(userId);
        SysVipInfo loginUser = userCacheManager.getLoginUser();
        refundRecord.setUserId(loginUser.getId());
        List<ShopRefundRecord> list = refundRecordDao.selectByRefundUserId(refundRecord);
        AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, list, list.size());
        return result;