zhaowenxuan
2024-10-16 cd6114bf85d19e6bdcd6a17c66f34b8c838870d5
ltkj-admin/src/main/java/com/ltkj/web/controller/mall/WxMallOrderController.java
@@ -2,6 +2,8 @@
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.github.binarywang.wxpay.bean.notify.WxPayNotifyResponse;
@@ -17,6 +19,7 @@
import com.google.common.base.Joiner;
import com.ltkj.common.core.domain.AjaxResult;
import com.ltkj.common.exception.user.DataNotFoundException;
import com.ltkj.common.task.TaskService;
import com.ltkj.common.utils.IpUtil;
import com.ltkj.common.utils.JacksonUtil;
import com.ltkj.framework.config.UserHoder;
@@ -29,6 +32,7 @@
import com.ltkj.mall.mallOrderUtils.OrderUtil;
import com.ltkj.system.service.ISysConfigService;
import com.ltkj.web.config.redis.OrderDelayService;
import com.ltkj.web.wxUtils.WxUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
@@ -81,7 +85,8 @@
    private WxPayService wxPayService;
    @Resource
    private ITbTransitionService transitionService;
    @Autowired
    private TaskService taskService;
    @Resource
    private OrderDelayService delayService;
@@ -399,7 +404,6 @@
    /**
     * 微信付款成功或失败回调接口
     * <p>
     * TODO
     * 注意,这里pay-notify是示例地址,建议开发者应该设立一个隐蔽的回调地址
     *
     * @param request  请求内容
@@ -465,6 +469,53 @@
//        final MallTimeConfig one = mallTimeConfigService.getOne(wq);
//        one.setNowNum(one.getNowNum()-1);
//        mallTimeConfigService.updateById(one);
        //发订单信息给wx订阅服务消息————————————————start————————————————————————————————————————
        Map<String, Object> res = new HashMap<>();
        res.put("touser",UserHoder.getWxuser().getOpenid());
        res.put("template_id","Gzc2BgzSsEY9uki6FThNQRLD1_An6uqpSve3PaU58PQ");
        res.put("page","pages/mine/index");
        res.put("miniprogram_state","formal");
        //订阅消息参数值
        JSONObject data = new JSONObject();
        JSONObject amount3 = new JSONObject();
        amount3.put("value", order.getOrderSn());
        data.put("character_string2", amount3);
        JSONObject time4 = new JSONObject();
        String dateFormat = DateUtil.format(order.getCreateTime(), "yyyy-MM-dd HH:mm:ss");
        time4.put("value", dateFormat);
        data.put("time1", time4);
        final TjPackage byId = packageService.getById(order.getPacId());
        if (byId!=null){
            JSONObject thing5 = new JSONObject();
            thing5.put("value",byId.getPacName());
            data.put("thing3", thing5);
        }else {
            JSONObject thing5 = new JSONObject();
            thing5.put("value","体检项目");
            data.put("thing3", thing5);
        }
        JSONObject name1 = new JSONObject();
        name1.put("value",order.getActualPrice()+"元");
        data.put("amount4", name1);
        if (order.getPayId()!=null){
            JSONObject thing6 = new JSONObject();
            thing6.put("value", "已付款");
            data.put("phrase8", thing6);
        }else {
            JSONObject thing6 = new JSONObject();
            thing6.put("value", "未付款");
            data.put("phrase8", thing6);
        }
        WxUtil.sendCommonSubscribeMessage(res,data);
        //发订单信息给wx订阅服务消息————————————————end————————————————————————————————————————
        return AjaxResult.success();
    }
@@ -562,9 +613,6 @@
                return AjaxResult.error("订单退款失败");
            }
        }
        //TODO 发送邮件和短信通知,这里采用异步发送
        // 退款成功通知用户, 例如“您申请的订单退款 [ 单号:{1} ] 已成功,请耐心等待到账。”
        // 注意订单号只发后6位
        /*notifyService.notifySmsTemplate(order.getMobile(), NotifyType.REFUND,
                new String[]{order.getOrderSn().substring(8, 14)});*/
        orderService.updateById(order);