| @@ -1,6 +1,7 @@ | |||||
| package com.iformall.controller; | package com.iformall.controller; | ||||
| import com.alibaba.fastjson.JSON; | import com.alibaba.fastjson.JSON; | ||||
| import com.alibaba.fastjson.JSONArray; | |||||
| import com.alibaba.fastjson.JSONObject; | import com.alibaba.fastjson.JSONObject; | ||||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | ||||
| import com.github.binarywang.wxpay.bean.ecommerce.SignatureHeader; | import com.github.binarywang.wxpay.bean.ecommerce.SignatureHeader; | ||||
| @@ -173,6 +174,31 @@ public class WxOrderController extends BaseController { | |||||
| JSONObject jsonObject = JSONObject.parseObject(body); | JSONObject jsonObject = JSONObject.parseObject(body); | ||||
| String app_id = jsonObject.getString("app_id"); | String app_id = jsonObject.getString("app_id"); | ||||
| String open_id = jsonObject.getString("open_id"); | String open_id = jsonObject.getString("open_id"); | ||||
| //透传字段 | |||||
| String cp_extra = jsonObject.getString("cp_extra"); | |||||
| if(StringUtils.isBlank(cp_extra)){ | |||||
| map.put("err_no",ErrorCode.SYS_PARAMETER_NOT_NULL.getCode()); | |||||
| map.put("err_tips","缺少透传字段"); | |||||
| return map; | |||||
| } | |||||
| Map<String,Long> couponMap = new HashMap<>(); | |||||
| try{ | |||||
| JSONArray jsonArray = JSONObject.parseArray(cp_extra); | |||||
| for(int i=0;i<jsonArray.size();i++){ | |||||
| String couponId = jsonArray.getJSONObject(i).getString("couponId"); | |||||
| Long couponChannelId = jsonArray.getJSONObject(i).getLongValue("couponChannelId"); | |||||
| if(StringUtils.isNotBlank(couponId) && couponChannelId != null){ | |||||
| couponMap.put(couponId,couponChannelId); | |||||
| } | |||||
| } | |||||
| }catch(Exception e){ | |||||
| } | |||||
| if(couponMap.isEmpty()){ | |||||
| map.put("err_no",ErrorCode.SYS_PARAMETER_NOT_NULL.getCode()); | |||||
| map.put("err_tips","透传字段格式不正确"); | |||||
| return map; | |||||
| } | |||||
| //验证app | //验证app | ||||
| WxAppinfo appinfo = wxAppinfoService.getByAppId(app_id); | WxAppinfo appinfo = wxAppinfoService.getByAppId(app_id); | ||||
| if(appinfo == null || !EnumAppPlat.TOUTIAO.getCode().equals(appinfo.getPlat()) | if(appinfo == null || !EnumAppPlat.TOUTIAO.getCode().equals(appinfo.getPlat()) | ||||
| @@ -211,7 +237,7 @@ public class WxOrderController extends BaseController { | |||||
| List<PlatPushOrderSaveDto> list = new ArrayList<>(); | List<PlatPushOrderSaveDto> list = new ArrayList<>(); | ||||
| for (CreateOrderCallback.Good good:createOrderCallback.getGoods()) { | for (CreateOrderCallback.Good good:createOrderCallback.getGoods()) { | ||||
| PlatPushOrderSaveDto dto = new PlatPushOrderSaveDto(); | PlatPushOrderSaveDto dto = new PlatPushOrderSaveDto(); | ||||
| dto.setCouponChannelId(Long.parseLong(good.getGoodsId())); | |||||
| dto.setCouponChannelId(couponMap.get(good.getGoodsId())); | |||||
| dto.setCount(good.getQuantity()); | dto.setCount(good.getQuantity()); | ||||
| dto.setExtParam(good.getItemOrderInfoList().toString()); | dto.setExtParam(good.getItemOrderInfoList().toString()); | ||||
| list.add(dto); | list.add(dto); | ||||