| @@ -2,26 +2,38 @@ package com.iformall.controller.basic; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.annotation.SystemControllerLog; | import com.iformall.annotation.SystemControllerLog; | ||||
| import com.iformall.annotation.TenantIgnore; | |||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.controller.base.BaseController; | import com.iformall.controller.base.BaseController; | ||||
| import com.iformall.controller.mem.AsyncTask; | |||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.po.base.BaseEntity; | import com.iformall.domain.po.base.BaseEntity; | ||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.enums.*; | import com.iformall.enums.*; | ||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.service.*; | import com.iformall.service.*; | ||||
| import com.iformall.utils.Constant; | |||||
| import io.swagger.annotations.ApiImplicitParam; | import io.swagger.annotations.ApiImplicitParam; | ||||
| import io.swagger.annotations.ApiImplicitParams; | import io.swagger.annotations.ApiImplicitParams; | ||||
| import io.swagger.annotations.ApiOperation; | import io.swagger.annotations.ApiOperation; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.data.redis.core.StringRedisTemplate; | |||||
| import org.springframework.web.bind.annotation.*; | import org.springframework.web.bind.annotation.*; | ||||
| import org.springframework.web.multipart.MultipartFile; | |||||
| import java.io.BufferedInputStream; | |||||
| import java.io.File; | |||||
| import java.io.FileOutputStream; | |||||
| import java.io.IOException; | |||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| import java.util.Arrays; | import java.util.Arrays; | ||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Map; | import java.util.Map; | ||||
| import java.util.concurrent.TimeUnit; | |||||
| import java.util.stream.Collectors; | import java.util.stream.Collectors; | ||||
| /** | /** | ||||
| @@ -32,6 +44,9 @@ import java.util.stream.Collectors; | |||||
| public class TtMerchantPoiController extends BaseController { | public class TtMerchantPoiController extends BaseController { | ||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||||
| @Autowired | |||||
| private String fmUploadDir; | |||||
| @Autowired | @Autowired | ||||
| private TtMerchantPoiService ttMerchantPoiService; | private TtMerchantPoiService ttMerchantPoiService; | ||||
| @@ -41,6 +56,12 @@ public class TtMerchantPoiController extends BaseController { | |||||
| @Autowired | @Autowired | ||||
| private WxCouponService wxCouponService; | private WxCouponService wxCouponService; | ||||
| @Autowired | |||||
| StringRedisTemplate stringRedisTemplate; | |||||
| @Autowired | |||||
| private AsyncTask asyncTask; | |||||
| @ApiOperation("分页列表接口") | @ApiOperation("分页列表接口") | ||||
| @GetMapping("list") | @GetMapping("list") | ||||
| @ApiImplicitParams({ | @ApiImplicitParams({ | ||||
| @@ -213,4 +234,88 @@ public class TtMerchantPoiController extends BaseController { | |||||
| // return ttMerchantPoiService.spuStockSync(getTenantInfo(),couponChannelId); | // return ttMerchantPoiService.spuStockSync(getTenantInfo(),couponChannelId); | ||||
| // } | // } | ||||
| @TenantIgnore | |||||
| @PostMapping(value = "/importPoi", consumes = "multipart/*") | |||||
| @SystemControllerLog(description = "poi-导入数据") | |||||
| public ResultData importPoi(@RequestParam("file") MultipartFile mFile) { | |||||
| logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::importPoi"); | |||||
| if (mFile.isEmpty()) { | |||||
| throw new MallinkException(Result.ERROR, "上传文件不能为空"); | |||||
| } | |||||
| //得到当前用户ID | |||||
| final MallUserInfo user = getUser(); | |||||
| String userId = "" + user.getId(); | |||||
| String importKey = Constant.importMemPrev + userId; | |||||
| //查询当前用户得到的值是否为空,为空继续,不为空,返回模板正在导入 | |||||
| Boolean allCount = stringRedisTemplate.opsForHash().hasKey(importKey, "allCount"); | |||||
| if (allCount) { | |||||
| return new ResultData(Result.SUCCESS, "模板正在导入"); | |||||
| } | |||||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", 0 + ""); | |||||
| stringRedisTemplate.expire(importKey,30, TimeUnit.MINUTES); | |||||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allSuccessCount", 0 + ""); | |||||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "processCount", ""); | |||||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "failCount", ""); | |||||
| String fpath = fmUploadDir; | |||||
| File targetFile = new File(fpath); | |||||
| if (!targetFile.exists()) { | |||||
| targetFile.mkdirs(); | |||||
| } | |||||
| String fileName = "poi" + Math.round(Math.random() * 100000000000L); | |||||
| int dot = mFile.getOriginalFilename().lastIndexOf('.'); | |||||
| fileName = fileName + mFile.getOriginalFilename().substring(dot, mFile.getOriginalFilename().length()); | |||||
| File lFile = new File(fpath + File.separator + fileName); | |||||
| FileOutputStream fos = null; | |||||
| BufferedInputStream fs = null; | |||||
| try { | |||||
| fos = new FileOutputStream(lFile); | |||||
| fs = (BufferedInputStream) mFile.getInputStream(); | |||||
| byte[] buffer = new byte[1024]; | |||||
| int len = 0; | |||||
| while ((len = fs.read(buffer)) != -1) { | |||||
| fos.write(buffer, 0, len); | |||||
| } | |||||
| fos.close(); | |||||
| fs.close(); | |||||
| } catch (Exception e) { | |||||
| stringRedisTemplate.expire(importKey,3,TimeUnit.SECONDS); | |||||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", "1"); | |||||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "failCount", "1"); | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(ErrorCode.MEM_IMPORT_ERR.getCode(), "模板上传失败"); | |||||
| } finally { | |||||
| if (fos != null) { | |||||
| try { | |||||
| fos.close(); | |||||
| } catch (IOException e) { | |||||
| stringRedisTemplate.expire(importKey,3,TimeUnit.SECONDS); | |||||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", "1"); | |||||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "failCount", "1"); | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(ErrorCode.MEM_IMPORT_ERR.getCode(), "模板上传失败"); | |||||
| } | |||||
| } | |||||
| if (fs != null) { | |||||
| try { | |||||
| fs.close(); | |||||
| } catch (IOException e) { | |||||
| stringRedisTemplate.expire(importKey,3,TimeUnit.SECONDS); | |||||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", "1"); | |||||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "failCount", "1"); | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(ErrorCode.MEM_IMPORT_ERR.getCode(), "模板上传失败"); | |||||
| } | |||||
| } | |||||
| } | |||||
| asyncTask.importExcelPoiData(lFile, user, importKey); | |||||
| return new ResultData(Result.SUCCESS, "模板正在导入"); | |||||
| } | |||||
| } | } | ||||
| @@ -8,6 +8,8 @@ import cn.afterturn.easypoi.handler.inter.IExcelDataHandler; | |||||
| import com.iformall.domain.po.MallUserInfo; | import com.iformall.domain.po.MallUserInfo; | ||||
| import com.iformall.domain.po.WxTags; | import com.iformall.domain.po.WxTags; | ||||
| import com.iformall.domain.vo.CUserBaseInfoT; | import com.iformall.domain.vo.CUserBaseInfoT; | ||||
| import com.iformall.domain.vo.MerchantPoiT; | |||||
| import com.iformall.service.TtMerchantPoiService; | |||||
| import com.iformall.service.WxCUserBasicInfoService; | import com.iformall.service.WxCUserBasicInfoService; | ||||
| import com.iformall.service.WxTagsService; | import com.iformall.service.WxTagsService; | ||||
| import org.apache.shiro.session.UnknownSessionException; | import org.apache.shiro.session.UnknownSessionException; | ||||
| @@ -29,6 +31,9 @@ public class AsyncTask { | |||||
| @Autowired | @Autowired | ||||
| private WxCUserBasicInfoService wxCUserBasicInfoService; | private WxCUserBasicInfoService wxCUserBasicInfoService; | ||||
| @Autowired | |||||
| private TtMerchantPoiService ttMerchantPoiService; | |||||
| @Autowired | @Autowired | ||||
| private WxTagsService wxTagsService; | private WxTagsService wxTagsService; | ||||
| @@ -47,6 +52,18 @@ public class AsyncTask { | |||||
| } | } | ||||
| private class PoiExcelHandler extends ExcelDataHandlerDefaultImpl<MerchantPoiT> { | |||||
| @Override | |||||
| public Object importHandler(MerchantPoiT obj, String name, Object value) { | |||||
| if (value == null) { | |||||
| value = ""; | |||||
| } | |||||
| System.out.println(name + " + " + value.toString()); | |||||
| return super.importHandler(obj, name, value); | |||||
| } | |||||
| } | |||||
| private void set_redis_value(String importKey, String allCount, String allSuccessCount, String processCount, String failCount, boolean fail) { | private void set_redis_value(String importKey, String allCount, String allSuccessCount, String processCount, String failCount, boolean fail) { | ||||
| stringRedisTemplate.opsForHash().put(importKey, "allCount", allCount); | stringRedisTemplate.opsForHash().put(importKey, "allCount", allCount); | ||||
| stringRedisTemplate.opsForHash().put(importKey, "allSuccessCount", allSuccessCount); | stringRedisTemplate.opsForHash().put(importKey, "allSuccessCount", allSuccessCount); | ||||
| @@ -118,4 +135,64 @@ public class AsyncTask { | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @Async | |||||
| public void importExcelPoiData(File file, MallUserInfo user, String importKey) { | |||||
| ImportParams params = new ImportParams(); | |||||
| // 需要验证 | |||||
| params.setImportFields(new String[]{"服务商POI_ID", "POI名称", "省份", "城市", "地址", "经度", "纬度", "高德ID(非必填)", | |||||
| "已匹配POI_ID", "已匹配POI名称", "已匹配POI省份", "已匹配POI城市", "已匹配POI地址", "未匹配原因", "其他信息"}); | |||||
| IExcelDataHandler<MerchantPoiT> handler = new AsyncTask.PoiExcelHandler(); | |||||
| handler.setNeedHandlerFields(new String[]{"服务商POI_ID","已匹配POI_ID"}); | |||||
| params.setNeedVerify(true); | |||||
| ExcelImportResult<MerchantPoiT> datalist = null; | |||||
| try { | |||||
| datalist = ExcelImportUtil.importExcelMore(file, MerchantPoiT.class, params); | |||||
| } catch (Exception e) { | |||||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||||
| logger.error(e.getMessage()); | |||||
| // 删除缓存文件 | |||||
| file.delete(); | |||||
| return; | |||||
| } | |||||
| // 删除缓存文件 | |||||
| file.delete(); | |||||
| if(datalist == null) { | |||||
| logger.error("导入模板失败: 模板数据解析失败"); | |||||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||||
| return; | |||||
| } | |||||
| List<MerchantPoiT> successList = datalist.getList(); | |||||
| List<MerchantPoiT> failList = datalist.getFailList(); | |||||
| logger.info("验证通过的数量: " + successList.size()); | |||||
| logger.info("验证未通过的数量: " + failList.size()); | |||||
| int total = successList.size() + failList.size(); | |||||
| int all_success = successList.size(); | |||||
| int all_fail = failList.size(); | |||||
| //添加到redis里 | |||||
| set_redis_value(importKey, "" + total, "" + all_success, "0", "" + all_fail, total == all_fail); | |||||
| if(successList.size() > 0) { | |||||
| try { | |||||
| successList.parallelStream().forEach(poiBase -> { | |||||
| try { | |||||
| ttMerchantPoiService.importOneMem(user,importKey, poiBase); | |||||
| } catch (UnknownSessionException ue) { | |||||
| logger.error("session :"+ue.getMessage()); | |||||
| } | |||||
| }); | |||||
| } catch (Exception e) { | |||||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||||
| e.printStackTrace(); | |||||
| logger.error("导入模板失败:"+e.getMessage()); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -23,7 +23,8 @@ public class UrlCheck { | |||||
| || url.contains("/wxImportTemplate/importTemplate") | || url.contains("/wxImportTemplate/importTemplate") | ||||
| || url.contains("/invest/customer/importCustomer") | || url.contains("/invest/customer/importCustomer") | ||||
| || url.contains("/alipay/imageUpload") | || url.contains("/alipay/imageUpload") | ||||
| || url.contains("/video/upload"); | |||||
| || url.contains("/video/upload") | |||||
| || url.contains("/merchantPoi/importPoi"); | |||||
| } | } | ||||
| } | } | ||||
| @@ -25,6 +25,7 @@ import com.iformall.domain.vo.WxOrderCouponVo; | |||||
| import com.iformall.douyin.pay.TtPayService; | import com.iformall.douyin.pay.TtPayService; | ||||
| import com.iformall.douyin.pay.exception.TtPayException; | import com.iformall.douyin.pay.exception.TtPayException; | ||||
| import com.iformall.douyin.payv2.result.CreateOrderCallback; | import com.iformall.douyin.payv2.result.CreateOrderCallback; | ||||
| import com.iformall.douyin.payv2.result.RefundOrderCallback; | |||||
| import com.iformall.enums.*; | import com.iformall.enums.*; | ||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.interceptor.BodyReaderHttpServletRequestWrapper; | import com.iformall.interceptor.BodyReaderHttpServletRequestWrapper; | ||||
| @@ -249,7 +250,7 @@ public class WxOrderController extends BaseController { | |||||
| WxComposeOrder order = (WxComposeOrder) resultData.data; | WxComposeOrder order = (WxComposeOrder) resultData.data; | ||||
| Map<String, Object> data = new HashMap<>(); | Map<String, Object> data = new HashMap<>(); | ||||
| data.put("out_order_no",order.getMainOrderId().toString()); | data.put("out_order_no",order.getMainOrderId().toString()); | ||||
| data.put("pay_expire_seconds",15*60); | |||||
| data.put("pay_expire_seconds",14*60); | |||||
| data.put("order_entry_schema",wxOrderService.getOrderEntrySchema(order.getMainOrderId())); | data.put("order_entry_schema",wxOrderService.getOrderEntrySchema(order.getMainOrderId())); | ||||
| // List<Map<String,Object>> goodsValid = new ArrayList<>(); | // List<Map<String,Object>> goodsValid = new ArrayList<>(); | ||||
| // for (Long couponChannelId:order.getCouponChannelMap().keySet()) { | // for (Long couponChannelId:order.getCouponChannelMap().keySet()) { | ||||
| @@ -1069,7 +1070,7 @@ public class WxOrderController extends BaseController { | |||||
| // return openId; | // return openId; | ||||
| // } | // } | ||||
| @AuthIgnore | @AuthIgnore | ||||
| @ApiOperation(value = "抖音支付2.0退款回调推送订单", notes = "{\"couponChannelId\":\"String\",\"couponId\":\"String\",\"press\":\"String\",\"orderGroupId\":\"String\",\"formId\":\"String\"}") | |||||
| @ApiOperation(value = "抖音支付2.0退款回调推送订单", notes = "{}") | |||||
| @PostMapping("douyinRefundOrder") | @PostMapping("douyinRefundOrder") | ||||
| public Map<String,Object> douyinRefundOrder(HttpServletRequest request) { | public Map<String,Object> douyinRefundOrder(HttpServletRequest request) { | ||||
| SignatureHeader header = new SignatureHeader(); | SignatureHeader header = new SignatureHeader(); | ||||
| @@ -1081,11 +1082,80 @@ public class WxOrderController extends BaseController { | |||||
| String body = ((BodyReaderHttpServletRequestWrapper) request).getBody(); | String body = ((BodyReaderHttpServletRequestWrapper) request).getBody(); | ||||
| logger.info("抖音支付2.0退款回调---body{}"+body); | logger.info("抖音支付2.0退款回调---body{}"+body); | ||||
| Map<String, Object> map = new HashMap(); | Map<String, Object> map = new HashMap(); | ||||
| map.put("err_no",1001); | |||||
| map.put("err_tips","未找到支付信息"); | |||||
| map.put("err_no",ErrorCode.SYS_SERVER_ERROR.getCode()); | |||||
| map.put("err_tips","暂不支持"); | |||||
| return map; | return map; | ||||
| // try { | |||||
| // JSONObject jsonObject = JSONObject.parseObject(body); | |||||
| // String msg = jsonObject.getString("msg"); | |||||
| // | |||||
| // JSONObject msgObject = JSONObject.parseObject(msg); | |||||
| // String app_id = msgObject.getString("app_id"); | |||||
| // String open_id = msgObject.getString("open_id"); | |||||
| // | |||||
| // //验证app | |||||
| // WxAppinfo appinfo = wxAppinfoService.getByAppId(app_id); | |||||
| // if(appinfo == null || !EnumAppPlat.TOUTIAO.getCode().equals(appinfo.getPlat()) | |||||
| // || !EnumAppType.C.getCode().equals(appinfo.getType())){ | |||||
| // map.put("err_no",ErrorCode.APP_ID_NOT_FOUND.getCode()); | |||||
| // map.put("err_tips",ErrorCode.APP_ID_NOT_FOUND.getMessage()); | |||||
| // return map; | |||||
| // } | |||||
| // WxPayAccount payAccount = wxPayAccountService.getById(appinfo.getPayId()); | |||||
| // if(payAccount == null){ | |||||
| // map.put("err_no",ErrorCode.API_KEY_NOT_FOUND.getCode()); | |||||
| // map.put("err_tips","未找到支付配置"); | |||||
| // return map; | |||||
| // } | |||||
| // TenantEntity tenantEntity = new TenantEntity(); | |||||
| // tenantEntity.updateTenantInfo(appinfo); | |||||
| // //验证用户 | |||||
| // Long memberId = null; | |||||
| // TtCUser cuser = (TtCUser) cuserFactory.getCUserService(EnumAppPlat.TOUTIAO).getByOpenId(open_id, tenantEntity.getTenantId()); | |||||
| // if(cuser != null && cuser.getUserId() != null){ | |||||
| // memberId = cuser.getUserId(); | |||||
| // } | |||||
| // if(memberId == null){ | |||||
| // map.put("err_no",ErrorCode.USER_NOT_MEMBER.getCode()); | |||||
| // map.put("err_tips",ErrorCode.USER_NOT_MEMBER.getMessage()); | |||||
| // return map; | |||||
| // } | |||||
| // | |||||
| // TtPayService ttPayService = maUtil.getTtPayService(appinfo, payAccount); | |||||
| // RefundOrderCallback refundOrderCallback = ttPayService.refundOrderNotifyV2Result(body, header); | |||||
| // | |||||
| // ResultData resultData = wxRefundOrderService.ttCallBackCreateRefundOrder(tenantEntity,memberId,refundOrderCallback); | |||||
| // | |||||
| // if(resultData.code == 200){ | |||||
| // WxRefundOrder refundOrder = (WxRefundOrder) resultData.data; | |||||
| // Map<String, Object> data = new HashMap<>(); | |||||
| // data.put("out_refund_no",refundOrder.getId().toString()); | |||||
| // data.put("order_entry_schema",wxOrderService.getOrderEntrySchema(Long.parseLong(refundOrder.getPayOrderNo()))); | |||||
| // map.put("data",data); | |||||
| // map.put("err_no",0); | |||||
| // map.put("err_tips",resultData.message); | |||||
| // logger.info("resultData{}"+JSON.toJSONString(map)); | |||||
| // return map; | |||||
| // }else{ | |||||
| // map.put("err_no",resultData.code); | |||||
| // map.put("err_tips",resultData.message); | |||||
| // return map; | |||||
| // } | |||||
| // | |||||
| // } catch (TtPayException e) { | |||||
| // logger.error(e.getMessage()); | |||||
| // map.put("err_no",ErrorCode.SYS_BEAN_EMPTY_PROPERTY_ERROR.getCode()); | |||||
| // map.put("err_tips",e.getMessage()); | |||||
| // return map; | |||||
| // } catch (Exception e){ | |||||
| // logger.error(e.getMessage()); | |||||
| // map.put("err_no",ErrorCode.SYS_SERVER_ERROR.getCode()); | |||||
| // map.put("err_tips",e.getMessage()); | |||||
| // return map; | |||||
| // } | |||||
| } | } | ||||
| @@ -160,32 +160,39 @@ public class TtPayController extends BaseController { | |||||
| out_order_no = (String) pMap.get("cp_orderno"); | out_order_no = (String) pMap.get("cp_orderno"); | ||||
| } | } | ||||
| String way = (String) pMap.get("way");//2-支付宝,1-微信 | |||||
| String status = (String) pMap.get("status"); | |||||
| if (StringUtils.isNotBlank(out_order_no)) { | if (StringUtils.isNotBlank(out_order_no)) { | ||||
| try { | try { | ||||
| Long orderId = Long.valueOf(out_order_no); | Long orderId = Long.valueOf(out_order_no); | ||||
| WxPayOrder wxpayOrder = wxPayOrderService.getById(orderId, appinfo.getTenantId()); | WxPayOrder wxpayOrder = wxPayOrderService.getById(orderId, appinfo.getTenantId()); | ||||
| if(wxpayOrder == null){ | if(wxpayOrder == null){ | ||||
| TenantEntity tenantEntity = new TenantEntity(); | |||||
| tenantEntity.setTenantId(appinfo.getTenantId()); | |||||
| tenantEntity.setParentTenantId(appinfo.getParentTenantId()); | |||||
| WxBatchOrder batchOrder = wxOrderService.getWxBatchOrder(tenantEntity,orderId); | |||||
| if(batchOrder == null){ | |||||
| logger.error("未找到订单"+orderId); | |||||
| logger.error("未找到订单"+orderId); | |||||
| resultMap.put("err_tips","未找到订单"); | |||||
| }else{ | |||||
| PayQueryAdapterResult queryResult = payServiceFactory.getPayAdapterService(wxpayOrder.getPayVendor()).queryPayStatus(wxpayOrder, appinfo, payAccount); | |||||
| if (EnumPayStatus.PAY_STATUS_SUCCESS.getCode() == queryResult.getCode()) { | |||||
| WxComposeOrder composeOrder = orderFactory.getOrderAdapterService(wxpayOrder.getComposeOrder()).getComposeOrder(wxpayOrder.getOrderId(), wxpayOrder.getTenantId()); | |||||
| wxPayOrderService.handleSuccessOrder(wxpayOrder, composeOrder, queryResult, true,false); | |||||
| }else { | |||||
| if("CANCEL".equals(status)){ | |||||
| //取消订单 | |||||
| WxBatchOrder batchOrder = new WxBatchOrder(); | |||||
| batchOrder.updateTenantInfo(wxpayOrder); | |||||
| batchOrder.setId(orderId); | |||||
| wxOrderService.cancelOrderBatchOrder(batchOrder,wxpayOrder); | |||||
| } | |||||
| } | } | ||||
| } | |||||
| PayQueryAdapterResult queryResult = payServiceFactory.getPayAdapterService(wxpayOrder.getPayVendor()).queryPayStatus(wxpayOrder, appinfo, payAccount); | |||||
| if (EnumPayStatus.PAY_STATUS_SUCCESS.getCode() == queryResult.getCode()) { | |||||
| WxComposeOrder composeOrder = orderFactory.getOrderAdapterService(wxpayOrder.getComposeOrder()).getComposeOrder(wxpayOrder.getOrderId(), wxpayOrder.getTenantId()); | |||||
| wxPayOrderService.handleSuccessOrder(wxpayOrder, composeOrder, queryResult, true,false); | |||||
| resultMap.put("err_no",0); | |||||
| resultMap.put("err_tips","success"); | |||||
| } | } | ||||
| } catch (NumberFormatException e) { | } catch (NumberFormatException e) { | ||||
| logger.error("payOrderId参数不正确: " + toString() + ", e:" + e.getMessage()); | |||||
| logger.error("支付回调失败 payOrderId参数不正确: " + toString() + ", e:" + e.getMessage()); | |||||
| resultMap.put("err_tips","payOrderId参数异常"); | |||||
| } catch (Exception e) { | |||||
| logger.error("支付回调失败: " + e.getMessage()); | |||||
| resultMap.put("err_tips",e.getMessage()); | |||||
| } | } | ||||
| } | } | ||||
| resultMap.put("err_no",0); | |||||
| resultMap.put("err_tips","success"); | |||||
| }else if("refund".equals(type)){//退款回调 | }else if("refund".equals(type)){//退款回调 | ||||
| String cp_refundno,status; | String cp_refundno,status; | ||||
| Integer refund_amount; | Integer refund_amount; | ||||
| @@ -69,20 +69,20 @@ public class TtWebController extends BaseController { | |||||
| return resultMap; | return resultMap; | ||||
| } | } | ||||
| String header = request.getHeader("X-Douyin-Signature"); | |||||
| String sha1gen = SHA1.gen(appInfo.getSecret(), JSON.toJSONString(parameterMap)); | |||||
| //发邮件 | |||||
| String[] receivers = fmExceptionEmails.split(","); | |||||
| StringBuilder sb = new StringBuilder(); | |||||
| sb.append(DateUtils.date2String(new Date())); | |||||
| sb.append("\n"); | |||||
| sb.append("抖音开放平台通知{}"+JSON.toJSONString(parameterMap)); | |||||
| sb.append("\n"); | |||||
| sb.append("sha1gen{}"+sha1gen); | |||||
| sb.append("\n"); | |||||
| sb.append("header{}"+header); | |||||
| //发送邮件 | |||||
| mailService.sendSimpleMail(receivers, "抖音开放平台通知", sb.toString()); | |||||
| // String header = request.getHeader("X-Douyin-Signature"); | |||||
| // String sha1gen = SHA1.gen(appInfo.getSecret(), JSON.toJSONString(parameterMap)); | |||||
| // //发邮件 | |||||
| // String[] receivers = fmExceptionEmails.split(","); | |||||
| // StringBuilder sb = new StringBuilder(); | |||||
| // sb.append(DateUtils.date2String(new Date())); | |||||
| // sb.append("\n"); | |||||
| // sb.append("抖音开放平台通知{}"+JSON.toJSONString(parameterMap)); | |||||
| // sb.append("\n"); | |||||
| // sb.append("sha1gen{}"+sha1gen); | |||||
| // sb.append("\n"); | |||||
| // sb.append("header{}"+header); | |||||
| // //发送邮件 | |||||
| // mailService.sendSimpleMail(receivers, "抖音开放平台通知", sb.toString()); | |||||
| if("life_goods_audit".equals(event)){ | if("life_goods_audit".equals(event)){ | ||||
| @@ -501,6 +501,7 @@ public enum ErrorCode{ | |||||
| */ | */ | ||||
| WIWIDE_INFO_NOT_FOUND(23001,"迈外迪信息未找到"), | WIWIDE_INFO_NOT_FOUND(23001,"迈外迪信息未找到"), | ||||
| WIWIDE_INFO_NOT_READY(23002,"迈外迪信息未就绪"), | WIWIDE_INFO_NOT_READY(23002,"迈外迪信息未就绪"), | ||||
| WIWIDE_INFO_NOT_SUPPORT(23003,"迈外迪信息版本不支持"), | |||||
| /** | /** | ||||
| @@ -44,6 +44,10 @@ public class WxRefundOrder extends TenantEntity { | |||||
| private Integer refundOrderStatus; | private Integer refundOrderStatus; | ||||
| @io.swagger.annotations.ApiModelProperty(value="微信退款单号",name="refundId") | @io.swagger.annotations.ApiModelProperty(value="微信退款单号",name="refundId") | ||||
| private String refundId; | private String refundId; | ||||
| @io.swagger.annotations.ApiModelProperty(value="退款原因",name="refundReason") | |||||
| private String refundReason; | |||||
| @io.swagger.annotations.ApiModelProperty(value="退款补充说明",name="refundDescription") | |||||
| private String refundDescription; | |||||
| @io.swagger.annotations.ApiModelProperty(value="支付失败原因",name="failReason") | @io.swagger.annotations.ApiModelProperty(value="支付失败原因",name="failReason") | ||||
| private String failReason; | private String failReason; | ||||
| @@ -40,11 +40,11 @@ public class WxTemplateMsg extends TenantEntity { | |||||
| private boolean isc; | private boolean isc; | ||||
| // public String getTypeName(){ | |||||
| // if(this.getType() != null) { | |||||
| // this.typeName = EnumTemplateType.getEnum(this.getType()).getMessage(); | |||||
| // } | |||||
| // return typeName; | |||||
| // } | |||||
| public String getTypeName(){ | |||||
| if(this.getType() != null) { | |||||
| this.typeName = EnumTemplateType.getEnum(this.getType()).getMessage(); | |||||
| } | |||||
| return typeName; | |||||
| } | |||||
| } | } | ||||
| @@ -0,0 +1,70 @@ | |||||
| package com.iformall.domain.vo; | |||||
| import cn.afterturn.easypoi.excel.annotation.Excel; | |||||
| import com.baomidou.mybatisplus.annotation.TableField; | |||||
| import lombok.Data; | |||||
| import javax.validation.constraints.NotNull; | |||||
| import javax.validation.constraints.Pattern; | |||||
| import java.io.Serializable; | |||||
| import java.math.BigDecimal; | |||||
| @Data | |||||
| public class MerchantPoiT implements Serializable { | |||||
| @NotNull | |||||
| @Excel(name="服务商POI_ID",width = 20,orderNum = "1") | |||||
| @io.swagger.annotations.ApiModelProperty(value="门店ID",name="merchantId") | |||||
| private String merchantId; | |||||
| @Excel(name="POI名称",width = 20,orderNum = "2") | |||||
| @io.swagger.annotations.ApiModelProperty(value="POI名称",name="merchantName") | |||||
| private String merchantName; | |||||
| @Excel(name = "省份", width = 20, orderNum = "3") | |||||
| @io.swagger.annotations.ApiModelProperty(value="省份",name="merchantProvince") | |||||
| private String merchantProvince; | |||||
| @Excel(name="城市",width = 20,orderNum = "4") | |||||
| @io.swagger.annotations.ApiModelProperty(value="城市",name="merchantCity") | |||||
| private String merchantCity; | |||||
| @Excel(name="地址",width = 20,orderNum = "5") | |||||
| @io.swagger.annotations.ApiModelProperty(value="地址",name="merchantAddr") | |||||
| private String merchantAddr; | |||||
| @Excel(name="经度",width = 20,orderNum = "6") | |||||
| @io.swagger.annotations.ApiModelProperty(value="经度",name="longitude") | |||||
| private BigDecimal longitude; | |||||
| @Excel(name = "纬度", width = 20, orderNum = "7") | |||||
| @io.swagger.annotations.ApiModelProperty(value="纬度",name="latitude") | |||||
| private BigDecimal latitude; | |||||
| @Excel(name = "高德ID(非必填)", width = 20, orderNum = "8") | |||||
| @io.swagger.annotations.ApiModelProperty(value="高德ID(非必填)",name="amapId") | |||||
| private String amapId; | |||||
| @NotNull | |||||
| @Excel(name = "已匹配POI_ID", width = 20, orderNum = "9") | |||||
| @io.swagger.annotations.ApiModelProperty(value="已匹配POI_ID",name="poiId") | |||||
| private String poiId; | |||||
| @Excel(name = "已匹配POI名称", width = 20, orderNum = "10") | |||||
| @io.swagger.annotations.ApiModelProperty(value="已匹配POI名称",name="poiName") | |||||
| private String poiName; | |||||
| @Excel(name = "已匹配POI省份", width = 20, orderNum = "11") | |||||
| @io.swagger.annotations.ApiModelProperty(value="已匹配POI省份",name="province") | |||||
| private String province; | |||||
| @Excel(name = "已匹配POI城市", width = 20, orderNum = "12") | |||||
| @io.swagger.annotations.ApiModelProperty(value="已匹配POI城市",name="city") | |||||
| private String city; | |||||
| @Excel(name = "已匹配POI地址", width = 20, orderNum = "13") | |||||
| @io.swagger.annotations.ApiModelProperty(value="已匹配POI地址",name="address") | |||||
| private String address; | |||||
| @Excel(name = "未匹配原因", width = 20, orderNum = "14") | |||||
| @io.swagger.annotations.ApiModelProperty(value="未匹配原因",name="mismatchStatusDesc") | |||||
| private String mismatchStatusDesc; | |||||
| @Excel(name = "其他信息", width = 20, orderNum = "15") | |||||
| @io.swagger.annotations.ApiModelProperty(value="其他信息",name="extra") | |||||
| private String extra; | |||||
| } | |||||
| @@ -75,13 +75,18 @@ public class TtWebGoodsGetRequestExecutor implements RequestExecutor<String, Str | |||||
| try (CloseableHttpResponse response = requestHttp.getRequestHttpClient().execute(httpGet)) { | try (CloseableHttpResponse response = requestHttp.getRequestHttpClient().execute(httpGet)) { | ||||
| String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response); | String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response); | ||||
| logger.info("response{}"+responseContent); | logger.info("response{}"+responseContent); | ||||
| int code = 0; | |||||
| String msg = null; | |||||
| try { | |||||
| JSONObject jsonObject = JSON.parseObject(responseContent); | |||||
| JSONObject base = jsonObject.getJSONObject("base"); | |||||
| code = base.getInteger("gateway_code"); | |||||
| msg = base.getString("gateway_msg"); | |||||
| }catch(Exception e){} | |||||
| if(code != 0){ | |||||
| throw new WxErrorException(WxError.builder().errorCode(code).errorMsg(msg).build()); | |||||
| } | |||||
| return responseContent; | return responseContent; | ||||
| // JSONObject jsonObject = JSON.parseObject(responseContent); | |||||
| // JSONObject data = jsonObject.getJSONObject("data"); | |||||
| // WxError error = WxError.fromJson(data.toJSONString()); | |||||
| // if (error.getErrorCode() != 0) { | |||||
| // throw new WxErrorException(error); | |||||
| // } | |||||
| // return data.toString(); | // return data.toString(); | ||||
| } finally { | } finally { | ||||
| httpGet.releaseConnection(); | httpGet.releaseConnection(); | ||||
| @@ -80,6 +80,17 @@ public class TtWebGoodsPostRequestExecutor implements RequestExecutor<String, St | |||||
| if (responseContent.isEmpty()) { | if (responseContent.isEmpty()) { | ||||
| throw new WxErrorException(WxError.builder().errorCode(9999).errorMsg("无响应内容").build()); | throw new WxErrorException(WxError.builder().errorCode(9999).errorMsg("无响应内容").build()); | ||||
| } | } | ||||
| int code = 0; | |||||
| String msg = null; | |||||
| try { | |||||
| JSONObject jsonObject = JSON.parseObject(responseContent); | |||||
| JSONObject base = jsonObject.getJSONObject("base"); | |||||
| code = base.getInteger("gateway_code"); | |||||
| msg = base.getString("gateway_msg"); | |||||
| }catch(Exception e){} | |||||
| if(code != 0){ | |||||
| throw new WxErrorException(WxError.builder().errorCode(code).errorMsg(msg).build()); | |||||
| } | |||||
| return responseContent; | return responseContent; | ||||
| // if (responseContent.startsWith("<xml>")) { | // if (responseContent.startsWith("<xml>")) { | ||||
| @@ -1,21 +1,13 @@ | |||||
| package com.iformall.douyin.web.api.impl; | package com.iformall.douyin.web.api.impl; | ||||
| import com.alibaba.fastjson.JSONObject; | |||||
| import com.alibaba.fastjson.TypeReference; | import com.alibaba.fastjson.TypeReference; | ||||
| import com.google.gson.Gson; | import com.google.gson.Gson; | ||||
| import com.google.gson.GsonBuilder; | import com.google.gson.GsonBuilder; | ||||
| import com.google.gson.JsonObject; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.douyin.pay.exception.TtPayException; | |||||
| import com.iformall.douyin.payv2.request.CallBackSettingsRequest; | |||||
| import com.iformall.douyin.payv2.result.BaseTtPayResult; | |||||
| import com.iformall.douyin.web.api.*; | import com.iformall.douyin.web.api.*; | ||||
| import com.iformall.douyin.web.bean.*; | import com.iformall.douyin.web.bean.*; | ||||
| import com.iformall.exception.MallinkException; | |||||
| import lombok.AllArgsConstructor; | import lombok.AllArgsConstructor; | ||||
| import me.chanjar.weixin.common.error.WxError; | import me.chanjar.weixin.common.error.WxError; | ||||
| import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
| import me.chanjar.weixin.common.util.json.GsonHelper; | |||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| import java.util.HashMap; | import java.util.HashMap; | ||||
| @@ -15,27 +15,20 @@ import me.chanjar.weixin.common.util.DataUtils; | |||||
| import me.chanjar.weixin.common.util.http.*; | import me.chanjar.weixin.common.util.http.*; | ||||
| import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder; | import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder; | ||||
| import me.chanjar.weixin.common.util.http.apache.DefaultApacheHttpClientBuilder; | import me.chanjar.weixin.common.util.http.apache.DefaultApacheHttpClientBuilder; | ||||
| import me.chanjar.weixin.common.util.json.WxGsonBuilder; | |||||
| import org.apache.http.Consts; | |||||
| import org.apache.http.HttpEntity; | |||||
| import org.apache.http.HttpHost; | import org.apache.http.HttpHost; | ||||
| import org.apache.http.client.config.RequestConfig; | import org.apache.http.client.config.RequestConfig; | ||||
| import org.apache.http.client.methods.CloseableHttpResponse; | import org.apache.http.client.methods.CloseableHttpResponse; | ||||
| import org.apache.http.client.methods.HttpPost; | import org.apache.http.client.methods.HttpPost; | ||||
| import org.apache.http.entity.ContentType; | |||||
| import org.apache.http.entity.StringEntity; | |||||
| import org.apache.http.entity.mime.MultipartEntityBuilder; | |||||
| import org.apache.http.impl.client.BasicResponseHandler; | import org.apache.http.impl.client.BasicResponseHandler; | ||||
| import org.apache.http.impl.client.CloseableHttpClient; | import org.apache.http.impl.client.CloseableHttpClient; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.lang.reflect.Field; | |||||
| import java.nio.charset.Charset; | |||||
| import java.util.HashMap; | import java.util.HashMap; | ||||
| import java.util.Map; | import java.util.Map; | ||||
| import java.util.concurrent.locks.Lock; | import java.util.concurrent.locks.Lock; | ||||
| import static cn.binarywang.wx.miniapp.constant.WxMaConstants.ErrorCode.*; | |||||
| import static com.iformall.douyin.web.config.TtWebConstants.ErrorCode.*; | |||||
| /** | /** | ||||
| * @author | * @author | ||||
| @@ -242,9 +235,7 @@ public class TtWebServiceImpl implements TtWebService, RequestHttp<CloseableHttp | |||||
| /* | /* | ||||
| * 发生以下情况时尝试刷新access_token | * 发生以下情况时尝试刷新access_token | ||||
| */ | */ | ||||
| if (error.getErrorCode() == ERR_40001 | |||||
| || error.getErrorCode() == ERR_42001 | |||||
| || error.getErrorCode() == ERR_40014) { | |||||
| if (error.getErrorCode() == ERR_200104) { | |||||
| // 强制设置WxMaConfig的access token过期了,这样在下一次请求里就会刷新access token | // 强制设置WxMaConfig的access token过期了,这样在下一次请求里就会刷新access token | ||||
| this.getTtWebConfig().expireAccessToken(); | this.getTtWebConfig().expireAccessToken(); | ||||
| if (this.getTtWebConfig().autoRefreshToken()) { | if (this.getTtWebConfig().autoRefreshToken()) { | ||||
| @@ -0,0 +1,24 @@ | |||||
| package com.iformall.douyin.web.config; | |||||
| /** | |||||
| * <pre> | |||||
| * 小程序常量. | |||||
| * </pre> | |||||
| * | |||||
| * @author <a href="https://github.com/binarywang">Binary Wang</a> | |||||
| */ | |||||
| public class TtWebConstants { | |||||
| /** | |||||
| * 微信接口返回的参数errcode. | |||||
| */ | |||||
| public static final String ERRCODE = "errcode"; | |||||
| public static final class ErrorCode { | |||||
| /** | |||||
| * 200104 token已过期 | |||||
| */ | |||||
| public static final int ERR_200104 = 200104; | |||||
| } | |||||
| } | |||||
| @@ -2,8 +2,10 @@ package com.iformall.service; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.MallUserInfo; | |||||
| import com.iformall.domain.po.TtMerchantPoi; | import com.iformall.domain.po.TtMerchantPoi; | ||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.domain.vo.MerchantPoiT; | |||||
| import com.iformall.douyin.web.api.TtWebService; | import com.iformall.douyin.web.api.TtWebService; | ||||
| import java.util.List; | import java.util.List; | ||||
| @@ -53,4 +55,6 @@ public interface TtMerchantPoiService { | |||||
| // ResultData spuStockSync(TenantEntity tenantInfo, Long couponChannelId); | // ResultData spuStockSync(TenantEntity tenantInfo, Long couponChannelId); | ||||
| void importOneMem(MallUserInfo user, String importKey, MerchantPoiT poiBase); | |||||
| } | } | ||||
| @@ -4,6 +4,7 @@ import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.douyin.payv2.result.RefundOrderCallback; | |||||
| import com.iformall.enums.EnumPayType; | import com.iformall.enums.EnumPayType; | ||||
| import com.iformall.enums.EnumPayWay; | import com.iformall.enums.EnumPayWay; | ||||
| @@ -102,4 +103,13 @@ public interface WxRefundOrderService { | |||||
| void actionAfterCouponOrder(WxOrder wxOrder, WxCUserBasicInfo basicInfo); | void actionAfterCouponOrder(WxOrder wxOrder, WxCUserBasicInfo basicInfo); | ||||
| WxRefundOrder findRefundOrder(TenantEntity tenantInfo, Long orderId); | WxRefundOrder findRefundOrder(TenantEntity tenantInfo, Long orderId); | ||||
| /** | |||||
| * 抖音2.0 退款回调创建退款订单 | |||||
| * @param tenantEntity | |||||
| * @param memberId | |||||
| * @param refundOrderCallback | |||||
| * @return | |||||
| */ | |||||
| ResultData ttCallBackCreateRefundOrder(TenantEntity tenantEntity, Long memberId, RefundOrderCallback refundOrderCallback); | |||||
| } | } | ||||
| @@ -1,5 +1,6 @@ | |||||
| package com.iformall.service.impl; | package com.iformall.service.impl; | ||||
| import com.alibaba.fastjson.JSON; | |||||
| import com.alibaba.fastjson.JSONArray; | 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; | ||||
| @@ -546,11 +547,11 @@ public class DataTowerServiceImpl implements DataTowerService { | |||||
| return m.getResult(); | return m.getResult(); | ||||
| })); | })); | ||||
| Map<Object, Object> historymap = new LinkedHashMap<>(); | |||||
| Map<String, String> historymap = new LinkedHashMap<>(); | |||||
| for (String date : tjTimeList) { | for (String date : tjTimeList) { | ||||
| Object o = collect.get(date); | |||||
| String o = collect.get(date); | |||||
| if (o == null) { | if (o == null) { | ||||
| historymap.put(date.substring(5).replace("-", "/"), 0L); | |||||
| historymap.put(date.substring(5).replace("-", "/"), "0"); | |||||
| } else { | } else { | ||||
| historymap.put(date.substring(5).replace("-", "/"), o); | historymap.put(date.substring(5).replace("-", "/"), o); | ||||
| } | } | ||||
| @@ -587,14 +588,14 @@ public class DataTowerServiceImpl implements DataTowerService { | |||||
| })); | })); | ||||
| List<String> days = DateUtils.getTjTimeList(oneWeekStartdate, oneWeekEndDate, "0"); | List<String> days = DateUtils.getTjTimeList(oneWeekStartdate, oneWeekEndDate, "0"); | ||||
| TreeMap<String, Object> weekMap = new TreeMap<>(); | |||||
| TreeMap<String, String> weekMap = new TreeMap<>(); | |||||
| for (String date:days) { | for (String date:days) { | ||||
| String dateStr = date.substring(5,date.length()).replace("-","/"); | String dateStr = date.substring(5,date.length()).replace("-","/"); | ||||
| Object o = weekCollect.get(dateStr); | |||||
| String o = weekCollect.get(dateStr); | |||||
| if(o == null) { | if(o == null) { | ||||
| weekMap.put(dateStr,"0"); | weekMap.put(dateStr,"0"); | ||||
| } else { | } else { | ||||
| weekMap.put(dateStr,o.toString()); | |||||
| weekMap.put(dateStr,o); | |||||
| } | } | ||||
| } | } | ||||
| datamap.put("oneWeekCarPayFeeCount",weekMap); | datamap.put("oneWeekCarPayFeeCount",weekMap); | ||||
| @@ -609,14 +610,14 @@ public class DataTowerServiceImpl implements DataTowerService { | |||||
| }, m -> { | }, m -> { | ||||
| return m.getResult(); | return m.getResult(); | ||||
| })); | })); | ||||
| TreeMap<String, Object> weekCarMap = new TreeMap<>(); | |||||
| TreeMap<String, String> weekCarMap = new TreeMap<>(); | |||||
| for (String date:days) { | for (String date:days) { | ||||
| String dateStr = date.substring(5,date.length()).replace("-","/"); | String dateStr = date.substring(5,date.length()).replace("-","/"); | ||||
| Object o = weekCarCollect.get(dateStr); | |||||
| String o = weekCarCollect.get(dateStr); | |||||
| if(o == null) { | if(o == null) { | ||||
| weekCarMap.put(dateStr, "0"); | weekCarMap.put(dateStr, "0"); | ||||
| } else { | } else { | ||||
| weekCarMap.put(dateStr, o.toString()); | |||||
| weekCarMap.put(dateStr, o); | |||||
| } | } | ||||
| } | } | ||||
| datamap.put("oneWeekNewCarUserHistory",weekCarMap); | datamap.put("oneWeekNewCarUserHistory",weekCarMap); | ||||
| @@ -648,11 +649,13 @@ public class DataTowerServiceImpl implements DataTowerService { | |||||
| //今日车流量 | //今日车流量 | ||||
| logger.info("停车-今日车流量-开始"); | logger.info("停车-今日车流量-开始"); | ||||
| long todaycar = (long) historymap.get(DateUtils.getSystemTime("MM/dd")); | |||||
| datamap.put("todaycar", todaycar); | |||||
| String todaycarStr = historymap.get(DateUtils.getSystemTime("MM/dd")); | |||||
| datamap.put("todaycar", todaycarStr); | |||||
| long todaycar = Long.parseLong(todaycarStr); | |||||
| //环比 | //环比 | ||||
| String yesterday = DateUtils.getTimeBefore(1, new Date()); | String yesterday = DateUtils.getTimeBefore(1, new Date()); | ||||
| long yesterdaycar = (long) historymap.get(yesterday.substring(5).replace("-", "/")); | |||||
| String yesterdaycarStr = historymap.get(yesterday.substring(5).replace("-", "/")); | |||||
| long yesterdaycar = Long.parseLong(yesterdaycarStr); | |||||
| if (yesterdaycar > 0) { | if (yesterdaycar > 0) { | ||||
| double hbd = (double) (todaycar - yesterdaycar) / yesterdaycar * 100; | double hbd = (double) (todaycar - yesterdaycar) / yesterdaycar * 100; | ||||
| double hb = new BigDecimal(hbd).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); | double hb = new BigDecimal(hbd).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); | ||||
| @@ -665,7 +668,8 @@ public class DataTowerServiceImpl implements DataTowerService { | |||||
| //上周同期 | //上周同期 | ||||
| logger.info("停车-上周同期-开始"); | logger.info("停车-上周同期-开始"); | ||||
| String lastweek = DateUtils.getTimeBefore(7, new Date()); | String lastweek = DateUtils.getTimeBefore(7, new Date()); | ||||
| long last = (long) historymap.get(lastweek.substring(5).replace("-", "/")); | |||||
| String lastStr = historymap.get(lastweek.substring(5).replace("-", "/")); | |||||
| long last = Long.parseLong(lastStr); | |||||
| if (last > 0) { | if (last > 0) { | ||||
| double lasthbd = (double) (todaycar - last) / last * 100; | double lasthbd = (double) (todaycar - last) / last * 100; | ||||
| double lasthb = new BigDecimal(lasthbd).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); | double lasthb = new BigDecimal(lasthbd).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); | ||||
| @@ -910,6 +914,11 @@ public class DataTowerServiceImpl implements DataTowerService { | |||||
| return new ResultData(ErrorCode.WIWIDE_INFO_NOT_FOUND); | return new ResultData(ErrorCode.WIWIDE_INFO_NOT_FOUND); | ||||
| } | } | ||||
| wiWideInfo = list.get(0); | wiWideInfo = list.get(0); | ||||
| if(wiWideInfo.getOldPlat().intValue() == 1){ | |||||
| return new ResultData(ErrorCode.WIWIDE_INFO_NOT_SUPPORT); | |||||
| } | |||||
| List<Integer> cap = JSONArray.parseArray(wiWideInfo.getCapability(), Integer.class); | List<Integer> cap = JSONArray.parseArray(wiWideInfo.getCapability(), Integer.class); | ||||
| Integer dataType; | Integer dataType; | ||||
| try { | try { | ||||
| @@ -54,7 +54,7 @@ public class TtGoodsCategoryServiceImpl implements TtGoodsCategoryService { | |||||
| private List<String> getProductAdminIsNotShowKey(){ | private List<String> getProductAdminIsNotShowKey(){ | ||||
| List<String> keyList = new ArrayList<>(); | List<String> keyList = new ArrayList<>(); | ||||
| keyList.add("appointment"); //预约信息 默认不可预约 | |||||
| // keyList.add("appointment"); //预约信息 默认不可预约 | |||||
| keyList.add("auto_renew"); //是否开启自动延期 默认不开启 | keyList.add("auto_renew"); //是否开启自动延期 默认不开启 | ||||
| // keyList.add("bring_out_meal"); //是否可以外带餐食 默认否 | // keyList.add("bring_out_meal"); //是否可以外带餐食 默认否 | ||||
| // keyList.add("can_no_use_date");//不可使用日期 默认无 | // keyList.add("can_no_use_date");//不可使用日期 默认无 | ||||
| @@ -147,10 +147,12 @@ public class TtGoodsCategoryServiceImpl implements TtGoodsCategoryService { | |||||
| for (GoodsTemplateGet.ProductAttrs attr: productAttrs) { | for (GoodsTemplateGet.ProductAttrs attr: productAttrs) { | ||||
| //预约信息 默认不可预约 | //预约信息 默认不可预约 | ||||
| if("appointment".equals(attr.getKey())){ | if("appointment".equals(attr.getKey())){ | ||||
| JSONObject jsonObject = new JSONObject(); | |||||
| jsonObject.put("need_appointment",false); | |||||
| jsonObject.put("ahead_day_num",0); | |||||
| attr.setData(jsonObject.toJSONString()); | |||||
| if(StringUtils.isBlank(attr.getData())){ | |||||
| JSONObject jsonObject = new JSONObject(); | |||||
| jsonObject.put("need_appointment",false); | |||||
| jsonObject.put("ahead_day_num",0); | |||||
| attr.setData(jsonObject.toJSONString()); | |||||
| } | |||||
| } | } | ||||
| //是否开启自动延期 默认不开启 | //是否开启自动延期 默认不开启 | ||||
| else if("auto_renew".equals(attr.getKey())){ | else if("auto_renew".equals(attr.getKey())){ | ||||
| @@ -6,11 +6,11 @@ import com.github.pagehelper.PageHelper; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.google.gson.JsonArray; | import com.google.gson.JsonArray; | ||||
| import com.google.gson.JsonObject; | import com.google.gson.JsonObject; | ||||
| import com.google.gson.JsonParser; | |||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.domain.vo.MerchantPoiT; | |||||
| import com.iformall.douyin.web.api.TtWebService; | import com.iformall.douyin.web.api.TtWebService; | ||||
| import com.iformall.douyin.web.bean.*; | import com.iformall.douyin.web.bean.*; | ||||
| import com.iformall.enums.*; | import com.iformall.enums.*; | ||||
| @@ -20,16 +20,15 @@ import com.iformall.service.*; | |||||
| import com.iformall.utils.Constant; | import com.iformall.utils.Constant; | ||||
| import com.iformall.utils.MaUtil; | import com.iformall.utils.MaUtil; | ||||
| import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
| import me.chanjar.weixin.common.util.json.GsonHelper; | |||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.data.redis.core.StringRedisTemplate; | |||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import java.text.SimpleDateFormat; | |||||
| import java.util.*; | import java.util.*; | ||||
| import java.util.stream.Collectors; | |||||
| import java.util.concurrent.TimeUnit; | |||||
| /** | /** | ||||
| * @author gongbiao | * @author gongbiao | ||||
| @@ -69,6 +68,9 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService { | |||||
| @Autowired | @Autowired | ||||
| MaUtil maUtil; | MaUtil maUtil; | ||||
| @Autowired | |||||
| StringRedisTemplate stringRedisTemplate; | |||||
| @Override | @Override | ||||
| public PageInfo<TtMerchantPoi> listAsPage(TtMerchantPoi record, Integer pageIndex, Integer pageSize) { | public PageInfo<TtMerchantPoi> listAsPage(TtMerchantPoi record, Integer pageIndex, Integer pageSize) { | ||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> ttMerchantPoiMapper.findList(record)); | return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> ttMerchantPoiMapper.findList(record)); | ||||
| @@ -505,6 +507,60 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService { | |||||
| return ttWebService; | return ttWebService; | ||||
| } | } | ||||
| @Override | |||||
| public void importOneMem(MallUserInfo user, String importKey, MerchantPoiT poiBase) { | |||||
| if (StringUtils.isBlank(poiBase.getMerchantId())) { | |||||
| stringRedisTemplate.opsForHash().increment(importKey, "processCount", 1); | |||||
| logger.error("服务商POI_ID为空", poiBase.toString()); | |||||
| return; | |||||
| } | |||||
| if (StringUtils.isBlank(poiBase.getPoiId())) { | |||||
| stringRedisTemplate.opsForHash().increment(importKey, "processCount", 1); | |||||
| logger.error("已匹配POI_ID为空", poiBase.toString()); | |||||
| return; | |||||
| } | |||||
| try { | |||||
| Date now = new Date(); | |||||
| TtMerchantPoi merchantPoi = ttMerchantPoiMapper.selectById(Long.parseLong(poiBase.getMerchantId())); | |||||
| if(merchantPoi == null){ | |||||
| merchantPoi = new TtMerchantPoi(); | |||||
| } | |||||
| merchantPoi.updateTenantInfo(user); | |||||
| merchantPoi.setSupplierExtId(poiBase.getMerchantId()); | |||||
| merchantPoi.setMerchantName(poiBase.getMerchantName()); | |||||
| merchantPoi.setMerchantProvince(poiBase.getMerchantProvince()); | |||||
| merchantPoi.setMerchantCity(poiBase.getMerchantCity()); | |||||
| merchantPoi.setMerchantAddr(poiBase.getMerchantAddr()); | |||||
| merchantPoi.setLongitude(poiBase.getLongitude()); | |||||
| merchantPoi.setLatitude(poiBase.getLatitude()); | |||||
| merchantPoi.setAmapId(poiBase.getAmapId()); | |||||
| merchantPoi.setExtra(poiBase.getExtra()); | |||||
| merchantPoi.setPoiId(poiBase.getPoiId()); | |||||
| merchantPoi.setPoiName(poiBase.getPoiName()); | |||||
| merchantPoi.setProvince(poiBase.getProvince()); | |||||
| merchantPoi.setCity(poiBase.getCity()); | |||||
| merchantPoi.setAddress(poiBase.getAddress()); | |||||
| merchantPoi.setMatchStatus(EnumSupplierMathStatus.match_success.getCode()); | |||||
| merchantPoi.setUpdateDate(now); | |||||
| if(merchantPoi.getId() == null){ | |||||
| merchantPoi.setId(Long.parseLong(poiBase.getMerchantId())); | |||||
| merchantPoi.setCreateDate(now); | |||||
| ttMerchantPoiMapper.insert(merchantPoi); | |||||
| }else{ | |||||
| ttMerchantPoiMapper.updateById(merchantPoi); | |||||
| } | |||||
| } catch (Exception e) { | |||||
| stringRedisTemplate.opsForHash().increment(importKey, "processCount", 1); | |||||
| logger.error(e.getMessage()); | |||||
| return; | |||||
| } | |||||
| stringRedisTemplate.opsForHash().increment(importKey,"processCount",1); | |||||
| stringRedisTemplate.expire(importKey,10, TimeUnit.SECONDS); | |||||
| } | |||||
| // @Override | // @Override | ||||
| // public ResultData findPoi(TenantEntity tenantInfo, Long couponChannelId) { | // public ResultData findPoi(TenantEntity tenantInfo, Long couponChannelId) { | ||||
| // WxCouponChannel couponChannel = wxCouponChannelMapper.selectById(couponChannelId, tenantInfo.getTenantId()); | // WxCouponChannel couponChannel = wxCouponChannelMapper.selectById(couponChannelId, tenantInfo.getTenantId()); | ||||
| @@ -3655,12 +3655,12 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| updOrder.setExtParam(JSON.toJSONString(good.getItemOrderInfoList().get(i))); | updOrder.setExtParam(JSON.toJSONString(good.getItemOrderInfoList().get(i))); | ||||
| wxOrderMapper.updateById(updOrder); | wxOrderMapper.updateById(updOrder); | ||||
| } | } | ||||
| }else if(wxOrders.size() == 1){ | |||||
| WxOrder updOrder = new WxOrder(); | |||||
| updOrder.updateTenantInfo(tenantEntity); | |||||
| updOrder.setId(wxOrders.get(0).getId()); | |||||
| updOrder.setExtParam(JSON.toJSONString(good.getItemOrderInfoList())); | |||||
| wxOrderMapper.updateById(updOrder); | |||||
| // }else if(wxOrders.size() == 1){ | |||||
| // WxOrder updOrder = new WxOrder(); | |||||
| // updOrder.updateTenantInfo(tenantEntity); | |||||
| // updOrder.setId(wxOrders.get(0).getId()); | |||||
| // updOrder.setExtParam(JSON.toJSONString(good.getItemOrderInfoList())); | |||||
| // wxOrderMapper.updateById(updOrder); | |||||
| }else{ | }else{ | ||||
| return new ResultData(ErrorCode.SYS_PARAMETER_CAST_ERROR.getCode(),"数据异常"); | return new ResultData(ErrorCode.SYS_PARAMETER_CAST_ERROR.getCode(),"数据异常"); | ||||
| } | } | ||||
| @@ -1,6 +1,7 @@ | |||||
| package com.iformall.service.impl; | package com.iformall.service.impl; | ||||
| import com.alibaba.fastjson.JSON; | |||||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | ||||
| import com.github.pagehelper.PageHelper; | import com.github.pagehelper.PageHelper; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| @@ -12,6 +13,7 @@ import com.iformall.domain.po.*; | |||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.domain.po.msg.FmInsideOrderRefundMsg; | import com.iformall.domain.po.msg.FmInsideOrderRefundMsg; | ||||
| import com.iformall.domain.po.msg.WxMsgRecord; | import com.iformall.domain.po.msg.WxMsgRecord; | ||||
| import com.iformall.douyin.payv2.result.RefundOrderCallback; | |||||
| import com.iformall.enums.*; | import com.iformall.enums.*; | ||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.mapper.*; | import com.iformall.mapper.*; | ||||
| @@ -23,6 +25,7 @@ import com.iformall.service.pay.PayServiceFactory; | |||||
| import com.iformall.service.pay.service.pay.entity.PayQueryAdapterResult; | import com.iformall.service.pay.service.pay.entity.PayQueryAdapterResult; | ||||
| import com.iformall.service.pay.service.refund.entity.RefundAdapterResult; | import com.iformall.service.pay.service.refund.entity.RefundAdapterResult; | ||||
| import com.iformall.service.pay.service.refund.entity.RefundNotifyAdapterResult; | import com.iformall.service.pay.service.refund.entity.RefundNotifyAdapterResult; | ||||
| import com.iformall.utils.DateUtils; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| @@ -823,5 +826,193 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||||
| return wxRefundOrderMapper.selectOne(new QueryWrapper<>(refundOrderQ)); | return wxRefundOrderMapper.selectOne(new QueryWrapper<>(refundOrderQ)); | ||||
| } | } | ||||
| @Override | |||||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||||
| public ResultData ttCallBackCreateRefundOrder(TenantEntity tenantEntity, Long memberId, RefundOrderCallback refundOrderCallback) { | |||||
| String outOrderNo = refundOrderCallback.getOutOrderNo(); | |||||
| Long compseOrderId = Long.parseLong(outOrderNo); | |||||
| WxOrder wxOrderQ = new WxOrder(); | |||||
| wxOrderQ.updateTenantInfo(tenantEntity); | |||||
| wxOrderQ.setComposeOrderId(compseOrderId); | |||||
| List<WxOrder> wxOrderList = wxOrderMapper.findList(wxOrderQ); | |||||
| if(wxOrderList.size() == 1){ | |||||
| WxOrder wxOrder = wxOrderList.get(0); | |||||
| if (wxOrder == null) { | |||||
| logger.error("交易订单不存在:compseOrderId=" + compseOrderId); | |||||
| throw new MallinkException(ErrorCode.ORDER_IS_NOT_FIND); | |||||
| } | |||||
| if (wxOrder.getPayment() <= 0) { | |||||
| logger.error("订单支付金额小于等于0: " + wxOrder.toString()); | |||||
| throw new MallinkException(ErrorCode.REFUND_PAY_ORDER_IS_ZERO); | |||||
| } | |||||
| if(!EnumOrderStatus.ORDER_STATUS_PAYMENT_SUCCESS.getCode().equals(wxOrder.getOrderStatus()) | |||||
| && !EnumOrderStatus.ORDER_STATUS_COOPERATING_COMPLETE.getCode().equals(wxOrder.getOrderStatus())){ | |||||
| logger.error("交易订单状态不支持退款:" + EnumOrderStatus.getEnum(wxOrder.getOrderStatus()).getMessage()); | |||||
| throw new MallinkException(ErrorCode.ORDER_PAY_REFUND_FAIL); | |||||
| } | |||||
| WxCouponOrder couponOrderQ = new WxCouponOrder(); | |||||
| couponOrderQ.updateTenantInfo(tenantEntity); | |||||
| couponOrderQ.setOrderId(wxOrder.getId()); | |||||
| List<WxCouponOrder> couponOrderList = wxCouponOrderMapper.findList(couponOrderQ); | |||||
| if(couponOrderList == null || couponOrderList.isEmpty()){ | |||||
| logger.error("数据异常,券未找到:" + wxOrder.getId()); | |||||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL); | |||||
| } | |||||
| for (WxCouponOrder wxCouponOrder:couponOrderList) { | |||||
| if (wxCouponOrder.getCouponOrderStatus().equals(EnumCouponOrderStatus.COUPON_ORDER_INVALID.getCode())) { | |||||
| logger.error("已退款: couponOrder-" + wxCouponOrder.getCouponId()); | |||||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_OVER_TIME); | |||||
| } | |||||
| if (wxCouponOrder.getCouponOrderStatus().equals(EnumCouponOrderStatus.COUPON_ORDER_USED.getCode())) { | |||||
| logger.error("已经核销过的券: couponOrder-" + wxCouponOrder.getCouponId()); | |||||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_USED); | |||||
| } | |||||
| } | |||||
| Date currentDate = new Date(); | |||||
| //这里wx_order不创建退款订单了, 直接修改原订单 | |||||
| WxOrder updWxOrder = new WxOrder(); | |||||
| updWxOrder.setId(wxOrder.getId()); | |||||
| updWxOrder.updateTenantInfo(wxOrder); | |||||
| if(refundOrderCallback.getRefundSource().intValue() == 1){ | |||||
| updWxOrder.setPaymentType(EnumPayType.PAY_C_REFUND.getCode()); | |||||
| updWxOrder.setRefDetail("用户发起退款"); | |||||
| }else if(refundOrderCallback.getRefundSource().intValue() == 3){ | |||||
| updWxOrder.setPaymentType(EnumPayType.PAY_AUTO_REFUND.getCode()); | |||||
| updWxOrder.setRefDetail("过期退款"); | |||||
| }else{ | |||||
| logger.error("未知退款类型"); | |||||
| throw new MallinkException(ErrorCode.REFUND_NOT_ALLOW.getCode(),"未知退款类型"); | |||||
| } | |||||
| updWxOrder.setOrderStatus(EnumOrderStatus.ORDER_STATUS_PENDING_REFUND.getCode()); | |||||
| updWxOrder.setUpdateDate(currentDate); | |||||
| try { | |||||
| wxOrderMapper.updateById(updWxOrder); | |||||
| } catch (Exception e) { | |||||
| logger.error("db failed: wxOrder-" + wxOrder.getId() + ", e:" + e.getMessage()); | |||||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | |||||
| } | |||||
| for (WxCouponOrder wxCouponOrder:couponOrderList) { | |||||
| // 更改 couponOrder 状态 | |||||
| if (wxCouponOrder.getCouponType().equals(EnumCouponType.CARD_MULTIMCH.getCode())) { | |||||
| wxCouponOrder.setCouponOrderStatus(EnumCouponOrderStatus.CARD_RETURNED.getCode()); // 卡线下退款 | |||||
| } else { | |||||
| wxCouponOrder.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_INVALID.getCode()); //3退款,券作废 | |||||
| } | |||||
| if(refundOrderCallback.getRefundSource().intValue() == 1){ | |||||
| wxCouponOrder.setBUserId(EnumPayType.PAY_C_REFUND.getCode().longValue()); | |||||
| wxCouponOrder.setAUserId(EnumPayType.PAY_C_REFUND.getCode().longValue()); | |||||
| }else if(refundOrderCallback.getRefundSource().intValue() == 3){ | |||||
| wxCouponOrder.setBUserId(EnumPayType.PAY_AUTO_REFUND.getCode().longValue()); | |||||
| wxCouponOrder.setAUserId(EnumPayType.PAY_AUTO_REFUND.getCode().longValue()); | |||||
| } | |||||
| wxCouponOrder.setBMerchantId(0L); | |||||
| wxCouponOrder.setUpdateDate(new Date()); | |||||
| try { | |||||
| wxCouponOrderMapper.updateById(wxCouponOrder); | |||||
| } catch (Exception e) { | |||||
| logger.error("db failed: couponOrder-" + wxCouponOrder.getId() + ", e:" + e.getMessage()); | |||||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | |||||
| } | |||||
| // 卡退款,把卡余额设为0 | |||||
| if (wxCouponOrder.getCouponType().equals(EnumCouponType.CARD_MULTIMCH.getCode())) { | |||||
| WxCardInfo updateCardInfo = new WxCardInfo(); | |||||
| updateCardInfo.setId(wxCouponOrder.getId()); | |||||
| updateCardInfo.setRemainingAmount(0); | |||||
| try { | |||||
| cardInfoMapper.updateById(updateCardInfo); | |||||
| } catch (Exception e) { | |||||
| logger.error("db failed: wxCardInfo-" + wxCouponOrder.getId() + ", e:" + e.getMessage()); | |||||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | |||||
| } | |||||
| } | |||||
| } | |||||
| // WxPayOrder payOrderQ = new WxPayOrder(); | |||||
| // payOrderQ.updateTenantInfo(tenantEntity); | |||||
| // payOrderQ.setCUserId(wxOrder.getCUserId()); | |||||
| // payOrderQ.setOrderId(wxOrder.getComposeOrderId()); | |||||
| // payOrderQ.setPayOrderStatus(EnumPayStatus.PAY_STATUS_SUCCESS.getCode()); | |||||
| // | |||||
| // WxPayOrder payOrder = null; | |||||
| // List<WxPayOrder> list = wxPayOrderMapper.findList(payOrderQ); | |||||
| // if (list.size() > 0) { | |||||
| // if (list.size() > 1) { | |||||
| // return new ResultData(ErrorCode.PAY_ORDER_ERROR.getCode(),"异常:该订单找到多条支付信息wxpayorder!"); | |||||
| // } | |||||
| // payOrder = list.get(0); | |||||
| // } | |||||
| // if (payOrder == null) { | |||||
| // logger.error("支付订单不存在(payOrder不存在)"); | |||||
| // return new ResultData(ErrorCode.PAY_ORDER_NOT_FOUND); | |||||
| // } | |||||
| WxRefundOrder record = new WxRefundOrder(); | |||||
| record.updateTenantInfo(tenantEntity); | |||||
| record.setPayOrderNo(wxOrder.getComposeOrderId().toString()); | |||||
| record.setOrderId(wxOrder.getId()); | |||||
| // check 是否有退款订单 | |||||
| List<WxRefundOrder> refundList = wxRefundOrderMapper.findList(record); | |||||
| if (refundList.size() > 0) { | |||||
| logger.error("退款订单已存在, 无法再提交退款申请"); | |||||
| throw new MallinkException(ErrorCode.REFUND_ORDER_EXIST.getCode(), "退款订单已存在, 无法再提交退款申请"); | |||||
| } | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| // 创建退款订单 | |||||
| Long refundId = idWorker.nextId(); | |||||
| //String out_refund_id = String.valueOf(refundId); | |||||
| record.setId(refundId); | |||||
| record.setCreateTime(currentDate); | |||||
| record.setUpdateTime(currentDate); | |||||
| // 微信内部订单号 | |||||
| record.setTransactionId(refundOrderCallback.getOrderId()); | |||||
| record.setCUserId(memberId); | |||||
| record.setTotalFee(wxOrder.getPayment()); | |||||
| record.setRefundFee(refundOrderCallback.getRefundTotalAmount()); | |||||
| record.setRefundTimeStart(new Date(refundOrderCallback.getCreateRefundTime())); | |||||
| record.setRefundOrderStatus(EnumRefundStatus.REFUND_REQ_SUCCESS.getCode()); | |||||
| record.setRefundVendor(wxOrder.getPayVendor()); | |||||
| record.setRefundId(refundOrderCallback.getRefundId()); | |||||
| record.setRefundReason(JSON.toJSONString(refundOrderCallback.getRefundReason())); | |||||
| record.setRefundDescription(refundOrderCallback.getRefundDescription()); | |||||
| // 退款订单 | |||||
| try { | |||||
| int sqlRow = wxRefundOrderMapper.insert(record); | |||||
| if (sqlRow != 1) { | |||||
| logger.error("退款订单数据库插入出错: " + record.toString()); | |||||
| throw new MallinkException(ErrorCode.DB_FAIL); | |||||
| } | |||||
| } catch (Exception e) { | |||||
| logger.error("退款订单数据库插入出错: " + record.toString()); | |||||
| throw new MallinkException(ErrorCode.DB_FAIL); | |||||
| } | |||||
| try { | |||||
| sendInsideOrderRefundMsg(wxOrder); | |||||
| } catch (Exception e) { | |||||
| logger.error("订单成功通知用户error:" + e.getMessage(),e); | |||||
| } | |||||
| return new ResultData(Result.SUCCESS, "退款订单申请成功", record); | |||||
| }else{ | |||||
| logger.error("订单数据异常:compseOrderId " + compseOrderId); | |||||
| throw new MallinkException(ErrorCode.ORDER_PAY_REFUND_FAIL); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -119,7 +119,7 @@ public class TtMiniAppPayAdapterService extends BaseTtPayAdapterService implemen | |||||
| request.setTotalAmount(composeOrder.getPayment()); | request.setTotalAmount(composeOrder.getPayment()); | ||||
| request.setOpenId(openId); | request.setOpenId(openId); | ||||
| request.setOutOrderNo(record.getPayOrderNo()); | request.setOutOrderNo(record.getPayOrderNo()); | ||||
| request.setPayExpireSeconds(15*60); | |||||
| request.setPayExpireSeconds(14*60); | |||||
| TtPayUnifiedOrderV2Request.PageEntry pageEntry = new TtPayUnifiedOrderV2Request.PageEntry(); | TtPayUnifiedOrderV2Request.PageEntry pageEntry = new TtPayUnifiedOrderV2Request.PageEntry(); | ||||
| pageEntry.setPath(Constant.mainPageUrl); | pageEntry.setPath(Constant.mainPageUrl); | ||||
| Map<String,Object> paramMap = new HashMap<>(); | Map<String,Object> paramMap = new HashMap<>(); | ||||
| @@ -150,12 +150,12 @@ public class TtMiniAppPayAdapterService extends BaseTtPayAdapterService implemen | |||||
| updOrder.setExtParam(JSON.toJSONString(itemOrderInfo.getItemOrderDetail().get(i))); | updOrder.setExtParam(JSON.toJSONString(itemOrderInfo.getItemOrderDetail().get(i))); | ||||
| wxOrderMapper.updateById(updOrder); | wxOrderMapper.updateById(updOrder); | ||||
| } | } | ||||
| }else if(wxOrders.size() == 1){ | |||||
| WxOrder updOrder = new WxOrder(); | |||||
| updOrder.updateTenantInfo(appInfo); | |||||
| updOrder.setId(wxOrders.get(0).getId()); | |||||
| updOrder.setExtParam(JSON.toJSONString(itemOrderInfo.getItemOrderDetail())); | |||||
| wxOrderMapper.updateById(updOrder); | |||||
| // }else if(wxOrders.size() == 1){ | |||||
| // WxOrder updOrder = new WxOrder(); | |||||
| // updOrder.updateTenantInfo(appInfo); | |||||
| // updOrder.setId(wxOrders.get(0).getId()); | |||||
| // updOrder.setExtParam(JSON.toJSONString(itemOrderInfo.getItemOrderDetail())); | |||||
| // wxOrderMapper.updateById(updOrder); | |||||
| }else{ | }else{ | ||||
| throw new Exception("下单数据异常"); | throw new Exception("下单数据异常"); | ||||
| } | } | ||||
| @@ -99,7 +99,7 @@ public class TtPayShareService extends PayShareBaseAdapterService{ | |||||
| if(EnumProfitSharingOrderStatus.PROFIT_SHARING_UNKNOWN.getCode().equals(record.getSharingStatus())){ | if(EnumProfitSharingOrderStatus.PROFIT_SHARING_UNKNOWN.getCode().equals(record.getSharingStatus())){ | ||||
| return new PayShareResult(false, EnumProfitSharingOrderStatus.PROFIT_SHARING_UNKNOWN.getCode(),"分账准备中", null,null); | return new PayShareResult(false, EnumProfitSharingOrderStatus.PROFIT_SHARING_UNKNOWN.getCode(),"分账准备中", null,null); | ||||
| } | } | ||||
| String before3dayStr = DateUtils.getTimeBefore(3, new Date()); | |||||
| String before3dayStr = DateUtils.getTimeBefore(2, new Date()); | |||||
| Date before3day = DateUtils.stringToDate(before3dayStr); | Date before3day = DateUtils.stringToDate(before3dayStr); | ||||
| if(before3day.before(record.getCreateTime())){ | if(before3day.before(record.getCreateTime())){ | ||||
| return new PayShareResult(false, EnumProfitSharingOrderStatus.PROFIT_SHARING_READY.getCode(),"未满足D+3", null,null); | return new PayShareResult(false, EnumProfitSharingOrderStatus.PROFIT_SHARING_READY.getCode(),"未满足D+3", null,null); | ||||
| @@ -151,7 +151,7 @@ public class TtPayShareService extends PayShareBaseAdapterService{ | |||||
| if(EnumProfitSharingOrderStatus.PROFIT_SHARING_UNKNOWN.getCode().equals(record.getSharingStatus())){ | if(EnumProfitSharingOrderStatus.PROFIT_SHARING_UNKNOWN.getCode().equals(record.getSharingStatus())){ | ||||
| return new PayShareResult(false, EnumProfitSharingOrderStatus.PROFIT_SHARING_UNKNOWN.getCode(),"分账准备中", null,null); | return new PayShareResult(false, EnumProfitSharingOrderStatus.PROFIT_SHARING_UNKNOWN.getCode(),"分账准备中", null,null); | ||||
| } | } | ||||
| String before3dayStr = DateUtils.getTimeBefore(3, new Date()); | |||||
| String before3dayStr = DateUtils.getTimeBefore(2, new Date()); | |||||
| Date before3day = DateUtils.stringToDate(before3dayStr); | Date before3day = DateUtils.stringToDate(before3dayStr); | ||||
| if(before3day.before(record.getCreateTime())){ | if(before3day.before(record.getCreateTime())){ | ||||
| return new PayShareResult(false, EnumProfitSharingOrderStatus.PROFIT_SHARING_APPLY_FAILED.getCode(),"未满足D+3", null,null); | return new PayShareResult(false, EnumProfitSharingOrderStatus.PROFIT_SHARING_APPLY_FAILED.getCode(),"未满足D+3", null,null); | ||||
| @@ -338,7 +338,7 @@ public class TtPayShareService extends PayShareBaseAdapterService{ | |||||
| jo.put("amount", childOrderShare.getShareAmount() - darenTakeAmount); | jo.put("amount", childOrderShare.getShareAmount() - darenTakeAmount); | ||||
| jo.put("rateAmount", childOrderShare.getRateAmount()); | jo.put("rateAmount", childOrderShare.getRateAmount()); | ||||
| jo.put("realRateAmount", childOrderShare.getRateAmount()); | |||||
| jo.put("realRateAmount", childOrderShare.getRealRateAmount()); | |||||
| jo.put("commissionAmount", childOrderShare.getCommissionAmount()); | jo.put("commissionAmount", childOrderShare.getCommissionAmount()); | ||||
| jo.put("darenTakeAmount", darenTakeAmount); | jo.put("darenTakeAmount", darenTakeAmount); | ||||
| //jo.put("description",receiver.getReceiverComments()); //改为存ID, | //jo.put("description",receiver.getReceiverComments()); //改为存ID, | ||||
| @@ -85,6 +85,9 @@ public class Constant { | |||||
| public static final String importMemPrev = "importmem:"; | public static final String importMemPrev = "importmem:"; | ||||
| public static final String importInvestCustomerPrev = "importinvestcustomer:"; | public static final String importInvestCustomerPrev = "importinvestcustomer:"; | ||||
| // 导入POI | |||||
| public static final String importPoiPrev = "importpoi:"; | |||||
| //商品门店 | //商品门店 | ||||
| public static final String coupon_merchants_key = "coupon:merchants:"; | public static final String coupon_merchants_key = "coupon:merchants:"; | ||||
| @@ -377,7 +377,7 @@ | |||||
| </select> | </select> | ||||
| <select id="listSettleBillData" resultType="hashmap" parameterType="com.iformall.domain.vo.WxBillAll"> | <select id="listSettleBillData" resultType="hashmap" parameterType="com.iformall.domain.vo.WxBillAll"> | ||||
| select s.settle_number,s.id,s.merchant_id merchantId,'' shop_id shopId,s.tenant_id tenantId,parent_tenant_id parentTenantId,'结算单' name, 10 billTypeValue,'结算单' billType,0 needPay, | |||||
| select s.settle_number,s.id,s.merchant_id merchantId,'' shopId,s.tenant_id tenantId,parent_tenant_id parentTenantId,'结算单' name, 10 billTypeValue,'结算单' billType,0 needPay, | |||||
| settle_receive_pay receivePay,0 pay,0 owe,createtime receiveDate,'' pay_date payDate,DATEDIFF(now(),receive_date) expiredDay, | settle_receive_pay receivePay,0 pay,0 owe,createtime receiveDate,'' pay_date payDate,DATEDIFF(now(),receive_date) expiredDay, | ||||
| status,'' starttime,'' endtime,'' rentShopType,'' priceDetail, 0 freeze,0 latePayPrice,0 serviceChargePay | status,'' starttime,'' endtime,'' rentShopType,'' priceDetail, 0 freeze,0 latePayPrice,0 serviceChargePay | ||||
| @@ -194,34 +194,36 @@ | |||||
| <select id="getExpiriedCouponIdsByEndTime" resultType="Long"> | <select id="getExpiriedCouponIdsByEndTime" resultType="Long"> | ||||
| select distinct coupon_id from wx_coupon_channel | select distinct coupon_id from wx_coupon_channel | ||||
| where status = 0 and tenant_id = #{tenantId} and end_time < now() | |||||
| where status in (0,-1) and tenant_id = #{tenantId} and end_time < now() | |||||
| </select> | </select> | ||||
| <update id="offExpiriedCouponChannelByEndTime"> | <update id="offExpiriedCouponChannelByEndTime"> | ||||
| update wx_coupon_channel SET status = 1, update_date = now() | update wx_coupon_channel SET status = 1, update_date = now() | ||||
| where status = 0 and tenant_id = #{tenantId} and end_time < now() | |||||
| where status in (0,-1) and tenant_id = #{tenantId} and end_time < now() | |||||
| </update> | </update> | ||||
| <select id="getExpiriedCouponIdsByValidDate" resultType="Long"> | <select id="getExpiriedCouponIdsByValidDate" resultType="Long"> | ||||
| select distinct cc.coupon_id from wx_coupon_channel cc, wx_coupon c | select distinct cc.coupon_id from wx_coupon_channel cc, wx_coupon c | ||||
| where cc.coupon_id = c.id and c.valid_type = 1 and c.valid_end_date < now() | where cc.coupon_id = c.id and c.valid_type = 1 and c.valid_end_date < now() | ||||
| and cc.status = 0 and cc.tenant_id = #{tenantId} | |||||
| and cc.status in (0,-1) and cc.tenant_id = #{tenantId} | |||||
| </select> | </select> | ||||
| <update id="offExpiriedCouponChannelByValidDate"> | <update id="offExpiriedCouponChannelByValidDate"> | ||||
| update wx_coupon_channel cc, wx_coupon c SET cc.status = 1, cc.update_date = now() | update wx_coupon_channel cc, wx_coupon c SET cc.status = 1, cc.update_date = now() | ||||
| where cc.status = 0 and cc.tenant_id = #{tenantId} and cc.coupon_id = c.id and c.valid_type = 1 and c.valid_end_date < now() | |||||
| where cc.coupon_id = c.id and c.valid_type = 1 and c.valid_end_date < now() | |||||
| and cc.status in (0,-1) and cc.tenant_id = #{tenantId} | |||||
| </update> | </update> | ||||
| <select id="getExpiriedCouponIdsByCouponStatus" resultType="Long"> | <select id="getExpiriedCouponIdsByCouponStatus" resultType="Long"> | ||||
| select distinct cc.coupon_id from wx_coupon_channel cc, wx_coupon c | select distinct cc.coupon_id from wx_coupon_channel cc, wx_coupon c | ||||
| where cc.coupon_id = c.id and c.status = 1 | where cc.coupon_id = c.id and c.status = 1 | ||||
| and cc.status = 0 and cc.tenant_id = #{tenantId} | |||||
| and cc.status in (0,-1) and cc.tenant_id = #{tenantId} | |||||
| </select> | </select> | ||||
| <update id="offExpiriedCouponChannelByCouponStatus"> | <update id="offExpiriedCouponChannelByCouponStatus"> | ||||
| update wx_coupon_channel cc, wx_coupon c SET cc.status = 1, cc.update_date = now() | update wx_coupon_channel cc, wx_coupon c SET cc.status = 1, cc.update_date = now() | ||||
| where cc.status = 0 and cc.tenant_id = #{tenantId} and cc.coupon_id = c.id and c.status = 1 | |||||
| where cc.coupon_id = c.id and c.status = 1 | |||||
| and cc.status in (0,-1) and cc.tenant_id = #{tenantId} | |||||
| </update> | </update> | ||||
| <update id="offExpiriedCouponChannel2ByEndTime"> | <update id="offExpiriedCouponChannel2ByEndTime"> | ||||
| @@ -126,10 +126,5 @@ | |||||
| from wx_refund_order | from wx_refund_order | ||||
| <include refid="dynamicWhereConditions" /> | <include refid="dynamicWhereConditions" /> | ||||
| </select> | </select> | ||||
| </mapper> | </mapper> | ||||