From a50def0fefbe3c86ac3ad06e04e4722338e3994a Mon Sep 17 00:00:00 2001 From: xhxu Date: Mon, 14 Aug 2023 22:40:13 +0800 Subject: [PATCH] =?UTF-8?q?//=E6=94=AF=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../db/migration/V2023080800001_create.sql | 47 +++ .../db/migration/V2023080800002_update.sql | 2 + .../controller/MiniAppUserController.java | 237 +++++++++++++ .../controller/ProductController.java | 53 +++ .../controller/ProductOrderController.java | 146 ++++++++ .../controller/WxUserGrantController.java | 9 + .../schedule/ProductOrderSharingSchedule.java | 40 +++ .../java/com/iformall/domain/po/Product.java | 56 +++ .../com/iformall/domain/po/ProductOrder.java | 98 ++++++ .../domain/po/ProductOrderSharing.java | 60 ++++ .../com/iformall/domain/po/UserBasicFrom.java | 42 +++ .../iformall/domain/po/UserBasicProperty.java | 30 ++ .../domain/po/UserBasicPropertyLog.java | 49 +++ .../com/iformall/domain/po/WxAppinfo.java | 2 + .../iformall/douyin/pay/DouYinPayHelper.java | 13 +- .../enums/EnumProductOrderPayVendor.java | 51 +++ .../enums/EnumProductOrderSettleStatus.java | 38 ++ .../enums/EnumProductOrderStatus.java | 46 +++ .../com/iformall/enums/EnumProductType.java | 52 +++ .../com/iformall/enums/EnumProfitSharing.java | 36 ++ .../java/com/iformall/enums/EnumProject.java | 41 +++ .../iformall/enums/EnumPropertyLogType.java | 38 ++ .../com/iformall/enums/EnumUserBasicFrom.java | 40 +++ .../com/iformall/mapper/ProductMapper.java | 12 + .../iformall/mapper/ProductOrderMapper.java | 13 + .../iformall/mapper/UserBasicFromMapper.java | 12 + .../mapper/UserBasicPropertyLogMapper.java | 12 + .../mapper/UserBasicPropertyMapper.java | 13 + .../main/java/com/iformall/pay/WxPayV3.java | 39 ++- .../iformall/service/ProductOrderService.java | 36 ++ .../com/iformall/service/ProductService.java | 19 + .../service/UserBasicFromService.java | 20 ++ .../service/UserBasicPropertyLogService.java | 18 + .../service/UserBasicPropertyService.java | 21 ++ .../iformall/service/WxAppinfoService.java | 5 + .../service/cuser/BasicCUserService.java | 85 ++--- .../service/cuser/CUserServiceApapter.java | 8 +- .../cuser/tt/TtBUserServiceAdapter.java | 283 --------------- .../cuser/tt/TtCUserServiceAdapter.java | 52 +-- .../cuser/wx/WxBUserServiceAdapter.java | 328 ------------------ .../cuser/wx/WxCUserServiceAdapter.java | 68 ++-- .../helper/WxPayOrderServiceHelper.java | 19 + .../service/impl/ProductOrderServiceImpl.java | 212 +++++++++++ .../service/impl/ProductServiceImpl.java | 35 ++ .../impl/UserBasicFromServiceImpl.java | 46 +++ .../impl/UserBasicPropertyLogServiceImpl.java | 29 ++ .../impl/UserBasicPropertyServiceImpl.java | 95 +++++ .../service/impl/WxAppinfoServiceImpl.java | 36 +- .../impl/WxCUserBasicInfoServiceImpl.java | 1 + .../service/pay/PayServiceFactory.java | 44 +++ .../pay/service/pay/PayAdapterService.java | 11 + .../miniApp/TtMiniAppPayAdapterService.java | 42 +++ .../pay/entity/PayQueryAdapterResult.java | 21 +- .../pay/wx/sft/h5/WxH5PaySFTService.java | 10 + .../appPay/WxMiniAppPaySFTAdapterService.java | 12 +- .../service/pay/wx/v2/h5/WxH5PayService.java | 10 + .../appPay/WxMiniAppPayAdapterService.java | 14 +- .../maPay/WxMiniMaPayAdapterService.java | 16 +- .../pay/wx/v3/entity/V3CreatePayReq.java | 17 + .../service/pay/wx/v3/entity/V3PayQuery.java | 13 + .../pay/service/pay/wx/v3/entity/V3Payer.java | 10 + .../appPay/WxMiniAppPayV3AdapterService.java | 136 ++++++-- .../java/com/iformall/utils/DateUtils.java | 14 + .../main/resources/mapper/ProductMapper.xml | 70 ++++ .../resources/mapper/ProductOrderMapper.xml | 141 ++++++++ .../resources/mapper/UserBasicFromMapper.xml | 58 ++++ .../mapper/UserBasicPropertyLogMapper.xml | 61 ++++ .../mapper/UserBasicPropertyMapper.xml | 52 +++ .../main/resources/mapper/WxAppinfoMapper.xml | 6 +- 69 files changed, 2678 insertions(+), 823 deletions(-) create mode 100644 suimangAdmin/src/main/resources/db/migration/V2023080800001_create.sql create mode 100644 suimangAdmin/src/main/resources/db/migration/V2023080800002_update.sql create mode 100644 suimangCApi/src/main/java/com/iformall/controller/MiniAppUserController.java create mode 100644 suimangCApi/src/main/java/com/iformall/controller/ProductController.java create mode 100644 suimangCApi/src/main/java/com/iformall/controller/ProductOrderController.java create mode 100644 suimangSchedule/src/main/java/com/iformall/schedule/ProductOrderSharingSchedule.java create mode 100644 suimangService/src/main/java/com/iformall/domain/po/Product.java create mode 100644 suimangService/src/main/java/com/iformall/domain/po/ProductOrder.java create mode 100644 suimangService/src/main/java/com/iformall/domain/po/ProductOrderSharing.java create mode 100644 suimangService/src/main/java/com/iformall/domain/po/UserBasicFrom.java create mode 100644 suimangService/src/main/java/com/iformall/domain/po/UserBasicProperty.java create mode 100644 suimangService/src/main/java/com/iformall/domain/po/UserBasicPropertyLog.java create mode 100644 suimangService/src/main/java/com/iformall/enums/EnumProductOrderPayVendor.java create mode 100644 suimangService/src/main/java/com/iformall/enums/EnumProductOrderSettleStatus.java create mode 100644 suimangService/src/main/java/com/iformall/enums/EnumProductOrderStatus.java create mode 100644 suimangService/src/main/java/com/iformall/enums/EnumProductType.java create mode 100644 suimangService/src/main/java/com/iformall/enums/EnumProfitSharing.java create mode 100644 suimangService/src/main/java/com/iformall/enums/EnumProject.java create mode 100644 suimangService/src/main/java/com/iformall/enums/EnumPropertyLogType.java create mode 100644 suimangService/src/main/java/com/iformall/enums/EnumUserBasicFrom.java create mode 100644 suimangService/src/main/java/com/iformall/mapper/ProductMapper.java create mode 100644 suimangService/src/main/java/com/iformall/mapper/ProductOrderMapper.java create mode 100644 suimangService/src/main/java/com/iformall/mapper/UserBasicFromMapper.java create mode 100644 suimangService/src/main/java/com/iformall/mapper/UserBasicPropertyLogMapper.java create mode 100644 suimangService/src/main/java/com/iformall/mapper/UserBasicPropertyMapper.java create mode 100644 suimangService/src/main/java/com/iformall/service/ProductOrderService.java create mode 100644 suimangService/src/main/java/com/iformall/service/ProductService.java create mode 100644 suimangService/src/main/java/com/iformall/service/UserBasicFromService.java create mode 100644 suimangService/src/main/java/com/iformall/service/UserBasicPropertyLogService.java create mode 100644 suimangService/src/main/java/com/iformall/service/UserBasicPropertyService.java delete mode 100644 suimangService/src/main/java/com/iformall/service/cuser/tt/TtBUserServiceAdapter.java delete mode 100644 suimangService/src/main/java/com/iformall/service/cuser/wx/WxBUserServiceAdapter.java create mode 100644 suimangService/src/main/java/com/iformall/service/impl/ProductOrderServiceImpl.java create mode 100644 suimangService/src/main/java/com/iformall/service/impl/ProductServiceImpl.java create mode 100644 suimangService/src/main/java/com/iformall/service/impl/UserBasicFromServiceImpl.java create mode 100644 suimangService/src/main/java/com/iformall/service/impl/UserBasicPropertyLogServiceImpl.java create mode 100644 suimangService/src/main/java/com/iformall/service/impl/UserBasicPropertyServiceImpl.java create mode 100644 suimangService/src/main/java/com/iformall/service/pay/service/pay/wx/v3/entity/V3CreatePayReq.java create mode 100644 suimangService/src/main/java/com/iformall/service/pay/service/pay/wx/v3/entity/V3PayQuery.java create mode 100644 suimangService/src/main/java/com/iformall/service/pay/service/pay/wx/v3/entity/V3Payer.java create mode 100644 suimangService/src/main/resources/mapper/ProductMapper.xml create mode 100644 suimangService/src/main/resources/mapper/ProductOrderMapper.xml create mode 100644 suimangService/src/main/resources/mapper/UserBasicFromMapper.xml create mode 100644 suimangService/src/main/resources/mapper/UserBasicPropertyLogMapper.xml create mode 100644 suimangService/src/main/resources/mapper/UserBasicPropertyMapper.xml diff --git a/suimangAdmin/src/main/resources/db/migration/V2023080800001_create.sql b/suimangAdmin/src/main/resources/db/migration/V2023080800001_create.sql new file mode 100644 index 0000000..1145b1e --- /dev/null +++ b/suimangAdmin/src/main/resources/db/migration/V2023080800001_create.sql @@ -0,0 +1,47 @@ +CREATE TABLE `user_basic_from` ( + `id` bigint(0) NOT NULL, + `tenant_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `parent_tenant_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `from_project` smallint(0) NOT NULL, + `from_type` smallint(0) DEFAULT NULL, + `from_id` bigint(0) DEFAULT NULL, + `from_user_id` bigint(0) DEFAULT NULL, + `create_date` datetime(0) NOT NULL, + `plat` smallint(0) DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic; + + +CREATE TABLE `user_basic_property` ( + `id` bigint(0) NOT NULL COMMENT '主键ID', + `tenant_id` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '租户ID', + `parent_tenant_id` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '父租户ID', + `digital_avatar_glod` int(0) DEFAULT NULL COMMENT '总金币', + `digital_avatar_residue_glod` int(0) DEFAULT 0 COMMENT '剩余金币', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户创建视频时间表' ROW_FORMAT = Dynamic; + + +CREATE TABLE `user_basic_property_log` ( + `id` bigint(0) NOT NULL COMMENT '主键ID', + `tenant_id` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '租户ID', + `parent_tenant_id` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '父租户ID', + `user_id` bigint(0) NOT NULL COMMENT '用户id(wx_c_user_basic_info.id)', + `project_type` smallint(0) NOT NULL, + `type` smallint(0) NOT NULL, + `befour_gold` int(0) DEFAULT NULL, + `gold_num` int(0) NOT NULL, + `after_gold` int(0) DEFAULT NULL, + `extra_id` bigint(0) DEFAULT NULL, + `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '备注', + `detail` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `create_date` datetime(0) DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户创建视频记录表' ROW_FORMAT = Dynamic; + + + + +product +product_order +product_order_sharing diff --git a/suimangAdmin/src/main/resources/db/migration/V2023080800002_update.sql b/suimangAdmin/src/main/resources/db/migration/V2023080800002_update.sql new file mode 100644 index 0000000..8716ca6 --- /dev/null +++ b/suimangAdmin/src/main/resources/db/migration/V2023080800002_update.sql @@ -0,0 +1,2 @@ +ALTER TABLE `wx_appinfo` +ADD COLUMN `project_type` smallint(0) AFTER `pay_id`; \ No newline at end of file diff --git a/suimangCApi/src/main/java/com/iformall/controller/MiniAppUserController.java b/suimangCApi/src/main/java/com/iformall/controller/MiniAppUserController.java new file mode 100644 index 0000000..7a4b4cb --- /dev/null +++ b/suimangCApi/src/main/java/com/iformall/controller/MiniAppUserController.java @@ -0,0 +1,237 @@ +package com.iformall.controller; + +import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; +import com.alibaba.fastjson.JSONObject; +import com.google.code.kaptcha.Producer; +import com.iformall.annotation.AuthIgnore; +import com.iformall.annotation.TenantIgnore; +import com.iformall.common.ErrorCode; +import com.iformall.common.Result; +import com.iformall.common.ResultData; +import com.iformall.domain.po.*; +import com.iformall.domain.po.sm.InviteCodeInfo; +import com.iformall.enums.*; +import com.iformall.exception.MallinkException; +import com.iformall.service.*; +import com.iformall.service.cuser.CUserServiceFactory; +import com.iformall.service.sm.InviteCodeInfoService; +import com.iformall.service.sm.InviteCodeService; +import com.iformall.service.sm.UserConsumptionPackageService; +import com.iformall.service.sm.UserCreateVideoNumService; +import com.iformall.utils.Constant; +import com.iformall.utils.IPUtil; +import com.iformall.utils.PasswordHelper; +import com.iformall.utils.RedisCacheUtils; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.imageio.ImageIO; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@RestController +@RequestMapping("/api/miniApp") +@Api(description = "用户登陆相关接口") +public class MiniAppUserController extends BaseController { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Autowired + private CUserServiceFactory cuserFactory; + + @Autowired + @Qualifier("objectCommonRedisTemplate") + RedisTemplate redisTemplate; + + @Autowired + private WxCUserBasicInfoService wxCUserBasicInfoService; + + @Autowired + WxAppinfoService wxAppinfoService; + + + /** + * 用户登录 + * 小程序登陆 + * + * @param map + * @return + */ + @AuthIgnore + @TenantIgnore + @PostMapping("/login") + @ApiOperation(value = "用户登录", notes = "{\"appId\":\"string\",\"code\":\"string\",\"scene\":\"string\",\"sceneAddress\":\"string\",\"latitude\":\"string\",\"longitude\":\"string\",\"systemInfo\":\"string\"}") + public ResultData userLogin(@RequestBody Map map) { + logger.info("dologin >>>>>>>>>>>>>>>>>"+map.toString()); + + Map resultMap = new HashMap(); + + String appId = map.get("appId"); + String code = map.get("code"); + //登录凭证不能为空 + if (StringUtils.isBlank(appId)) { + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "appId不能为空"); + } + if (StringUtils.isBlank(code)) { + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "code不能为空"); + } + + WxAppinfo wxAppinfo = wxAppinfoService.getOnlyByAppIdFromRedis(appId); + if(wxAppinfo == null){ + return new ResultData(ErrorCode.APP_ID_NOT_FOUND); + } + if(!wxAppinfo.getEnable().equals(EnumEnableType.Enable.getCode())){ + return new ResultData(ErrorCode.APP_ID_NOT_ENABLE); + } + EnumAppPlat appPlat = EnumAppPlat.getByCode(wxAppinfo.getPlat()); + if(appPlat == null){ + return new ResultData(ErrorCode.APP_PLAT_ERROR); + } + + String session_key = null; + String openId = null; + String unionId = null; + + try { + WxMaJscode2SessionResult session = cuserFactory.getCUserService(appPlat).jsCode2SessionInfo(code, wxAppinfo, false); + logger.info("sessionResult: " + session); + if (null != session) { + logger.info("sessionResultDetail: [openid]" + session.getOpenid()+",[sessionkey]"+session.getSessionKey()+",[unionid]"+session.getUnionid()); + } + + //获取会话密钥(session_key) + session_key = session.getSessionKey(); + openId = session.getOpenid(); + unionId = session.getUnionid(); + + logger.info("session_key: " + session_key + ", openId: " + openId + ", unionId: " + unionId); + resultMap.put("openId", openId); + } catch (Exception e) { + logger.error(e.getMessage(), e); + return new ResultData(ErrorCode.SESSION_KEY_DECODE_ERR, resultMap); + } + + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); +// request.setAttribute(Constant.TENANT_ID, wxMall.getTenantId()); +// request.setAttribute(Constant.PARENT_TENANT_ID, wxMall.getParentTenantId()); + String ipaddress = IPUtil.getIpAddr(request); + + CUser cUser = new CUser(); + cUser.setAppId(appId); + cUser.setOpenId(openId); + + cUser.setUnionId(unionId); + cUser.setRegisterIp(ipaddress); + cUser.setSessionKey(session_key); + + //处理登陆用户 + cUser = cuserFactory.getCUserService(appPlat).handleLoginUser(cUser); + + if(cUser.getUserId() != null){ + WxCUserBasicInfo basicInfo = wxCUserBasicInfoService.getById(cUser.getUserId(), getTenantInfo().getTenantId()); + if(basicInfo != null){ + wxCUserBasicInfoService.handleLoginUser(basicInfo); + resultMap.put("token", basicInfo.getToken()); + } + } + return new ResultData(resultMap); + } + + /** + * 授权登陆 + * + * @param map + * @return + */ + @PostMapping("/loginPhone") + @ApiOperation(value = "授权后获取用户的手机号", notes = "{\"encryptedData\":\"string\",\"iv\":\"string\"}") + public ResultData getUserPhone(@RequestBody Map map) { + logger.info(map.toString()); + String appId = map.get("appId"); + String openId = map.get("openId"); + String encryptedData = map.get("encryptedData"); + String iv = map.get("iv"); + + if(StringUtils.isBlank(appId)){ + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "appId 不能为空"); + } + if(StringUtils.isBlank(openId)){ + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "openId 不能为空"); + } + + WxAppinfo wxAppinfo = wxAppinfoService.getOnlyByAppIdFromRedis(appId); + if(wxAppinfo == null){ + return new ResultData(ErrorCode.APP_ID_NOT_FOUND); + } + if(!wxAppinfo.getEnable().equals(EnumEnableType.Enable.getCode())){ + return new ResultData(ErrorCode.APP_ID_NOT_ENABLE); + } + EnumAppPlat appPlat = EnumAppPlat.getByCode(wxAppinfo.getPlat()); + if(appPlat == null){ + return new ResultData(ErrorCode.APP_PLAT_ERROR); + } + + //登录凭证不能为空 + if (StringUtils.isBlank(encryptedData)) { + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "encryptedData 不能为空"); + } + if (StringUtils.isBlank(iv)) { + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "iv 不能为空"); + } + + String uid = map.get("uid"); + + UserBasicFrom from = new UserBasicFrom(); + from.setPlat(appPlat.getCode()); + from.setFromProject(EnumProject.PROJECT_5.getCode()); + if(StringUtils.isNotBlank(uid)){ + try { + from.setFromUserId(Long.parseLong(uid)); + from.setFromType(EnumUserBasicFrom.FROM_3.getCode()); + }catch(Exception e){} + } + + + + Map resultMap = new HashMap(); + + try { + CUser user = cuserFactory.getCUserService(appPlat).getByOpenId(openId, getTenantInfo().getTenantId()); + if (user == null) { + return new ResultData(ErrorCode.USER_IS_EMPTY); + } + // 解密 并注册 + WxCUserBasicInfo basicInfo = cuserFactory.getCUserService(user.getAppPlat()).decryptPhoneNoInfo(encryptedData, iv, user, wxAppinfo, false,from); + wxCUserBasicInfoService.handleLoginUser(basicInfo); + + resultMap.put("token", basicInfo.getToken()); + + } catch (MallinkException e) { + return new ResultData(e.getErrorCode(), e.getMessage()); + }catch (Exception e) { + this.logger.error(e.getMessage(), e); + return new ResultData(ErrorCode.DB_FAIL.getCode(), "解密并保存出错", resultMap); + } + + return new ResultData(resultMap); + } + +} diff --git a/suimangCApi/src/main/java/com/iformall/controller/ProductController.java b/suimangCApi/src/main/java/com/iformall/controller/ProductController.java new file mode 100644 index 0000000..abe8dbd --- /dev/null +++ b/suimangCApi/src/main/java/com/iformall/controller/ProductController.java @@ -0,0 +1,53 @@ +package com.iformall.controller; + +import com.github.pagehelper.PageInfo; +import com.iformall.annotation.AuthIgnore; +import com.iformall.common.ErrorCode; +import com.iformall.common.ResultData; +import com.iformall.domain.po.Product; +import com.iformall.domain.po.base.BaseEntity; +import com.iformall.domain.po.sm.PersonPhoto; +import com.iformall.enums.EnumMouldSendType; +import com.iformall.enums.EnumaMouldPatchStatus; +import com.iformall.service.ProductService; +import com.iformall.service.sm.MouldPatchSignService; +import com.iformall.service.sm.PersonPhotoService; +import com.iformall.utils.BaiduImageCheckUtil; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.ObjectUtils; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + + +@RestController +@RequestMapping("/api/product") +@Api(description = "模板接口") +public class ProductController extends BaseController { + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Autowired + private ProductService productService; + + @AuthIgnore + @ApiOperation("分页列表接口") + @GetMapping("list") + @ApiImplicitParams({ + @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), + @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) + public ResultData list(@ModelAttribute Product record, Integer pageNum, Integer pageSize) { + logger.debug("[" + getIpAddr() + "] ProductController::list"); + if (record == null) record = new Product(); + record.setSortColumns(BaseEntity.SortField.UpdateDate_DESC); + final PageInfo page = productService.listAsPage(record, pageNum, pageSize); + return new ResultData(page); + } + + +} diff --git a/suimangCApi/src/main/java/com/iformall/controller/ProductOrderController.java b/suimangCApi/src/main/java/com/iformall/controller/ProductOrderController.java new file mode 100644 index 0000000..587dbf4 --- /dev/null +++ b/suimangCApi/src/main/java/com/iformall/controller/ProductOrderController.java @@ -0,0 +1,146 @@ +package com.iformall.controller; + +import com.github.pagehelper.PageInfo; +import com.iformall.annotation.AuthIgnore; +import com.iformall.annotation.TenantIgnore; +import com.iformall.common.ErrorCode; +import com.iformall.common.Result; +import com.iformall.common.ResultData; +import com.iformall.domain.dto.OrderComposeSaveDto; +import com.iformall.domain.dto.OrderSaveDto; +import com.iformall.domain.po.CUser; +import com.iformall.domain.po.Product; +import com.iformall.domain.po.ProductOrder; +import com.iformall.domain.po.base.BaseEntity; +import com.iformall.domain.po.sm.PersonPhoto; +import com.iformall.enums.EnumComposeOrder; +import com.iformall.enums.EnumProductOrderPayVendor; +import com.iformall.enums.EnumProductOrderStatus; +import com.iformall.service.ProductOrderService; +import com.iformall.service.ProductService; +import com.iformall.service.pay.entity.PayExtraParam; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + + +@RestController +@RequestMapping("/api/productOrder") +@Api(description = "模板接口") +public class ProductOrderController extends BaseController { + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Autowired + private ProductOrderService productOrderService; + + @Autowired + private ProductService productService; + + @ApiOperation(value = "创建订单", notes = "") + @PostMapping("createOrder") + public ResultData createOrder(@RequestBody ProductOrder record) { + logger.debug("[" + getIpAddr() + "] ProductOrderController::createOrder"); + Long productId = record.getProductId(); + Integer payVendor = record.getPayVendor(); + if(productId == null){ + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"商品编号为空"); + } + if(payVendor == null){ + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"支付方式为空"); + } + + Product product = productService.getById(productId); + if(product == null){ + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未查询到商品"); + } + EnumProductOrderPayVendor payVendorEnum = EnumProductOrderPayVendor.getEnum(payVendor); + if(payVendorEnum == null){ + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"支付方式参数错误"); + } + + record = new ProductOrder(); + record.setUserId(getMemberId()); + record.setProductId(product.getId()); + record.setProductTitle(product.getTitle()); + record.setProductEnTitle(product.getEnTitle()); + record.setOrderStatus(EnumProductOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode()); + record.setProjectType(product.getProjectType()); + record.setPayVendor(payVendorEnum.getCode()); + record.setOrderPrice(product.getPriceRmb()); + + record.setProfitSharing(payVendorEnum.getProfitSharing()); + + productOrderService.saveOrUpdate(record); + return new ResultData(record.getOrderNumber()); + } + + @AuthIgnore + @ApiOperation("根据id查询接口") + @GetMapping("/findByNumber") + @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) + public ResultData findByNumber(String orderNumber) { + logger.debug("[" + getIpAddr() + "] ProductOrderController::findByNumber"); + + if(StringUtils.isBlank(orderNumber)){ + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"订单号为空"); + } + Long id = null; + try{ + id = Long.parseLong(orderNumber); + }catch (Exception e){ } + if(id == null){ + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"订单号异常"); + } + ProductOrder productOrder = productOrderService.getById(id); + if(productOrder == null){ + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未查询到订单"); + } + return new ResultData(productOrder); + } + + @AuthIgnore + @ApiOperation(value = "创建支付", notes = "") + @PostMapping("createPay") + public ResultData createPay(@RequestBody ProductOrder record){ + logger.debug("[" + getIpAddr() + "] ProductOrderController::createPay"); + String orderNumber = record.getOrderNumber(); + String openId = record.getOpenId(); + if(StringUtils.isBlank(orderNumber)){ + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"订单号为空"); + } + Long id = null; + try{ + id = Long.parseLong(orderNumber); + }catch (Exception e){ } + if(id == null){ + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"订单号异常"); + } + ProductOrder productOrder = productOrderService.getById(id); + if(productOrder == null){ + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未查询到订单"); + } + + if(EnumProductOrderPayVendor.PAY_WAY_WECHAT.getCode().equals(productOrder.getPayVendor())){ + if(StringUtils.isBlank(openId)){ + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"openId为空"); + } + } + + ResultData resultData = productOrderService.createPay(productOrder); + + return resultData; + } + + +} diff --git a/suimangCApi/src/main/java/com/iformall/controller/WxUserGrantController.java b/suimangCApi/src/main/java/com/iformall/controller/WxUserGrantController.java index bf06056..1c8e580 100644 --- a/suimangCApi/src/main/java/com/iformall/controller/WxUserGrantController.java +++ b/suimangCApi/src/main/java/com/iformall/controller/WxUserGrantController.java @@ -1,7 +1,11 @@ package com.iformall.controller; +import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import com.google.code.kaptcha.Producer; import com.iformall.annotation.AuthIgnore; +import com.iformall.annotation.TenantIgnore; import com.iformall.common.ErrorCode; import com.iformall.common.Result; import com.iformall.common.ResultData; @@ -15,6 +19,7 @@ import com.iformall.service.sm.InviteCodeService; import com.iformall.service.sm.UserConsumptionPackageService; import com.iformall.service.sm.UserCreateVideoNumService; import com.iformall.utils.Constant; +import com.iformall.utils.IPUtil; import com.iformall.utils.PasswordHelper; import com.iformall.utils.RedisCacheUtils; import io.swagger.annotations.Api; @@ -30,9 +35,12 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; import javax.imageio.ImageIO; import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.awt.image.BufferedImage; import java.io.IOException; @@ -99,6 +107,7 @@ public class WxUserGrantController extends BaseController { @Autowired private UserConsumptionPackageService userConsumptionPackageService; + @Autowired private WxCUserAuthorityService wxCUserAuthorityService; diff --git a/suimangSchedule/src/main/java/com/iformall/schedule/ProductOrderSharingSchedule.java b/suimangSchedule/src/main/java/com/iformall/schedule/ProductOrderSharingSchedule.java new file mode 100644 index 0000000..31c3b92 --- /dev/null +++ b/suimangSchedule/src/main/java/com/iformall/schedule/ProductOrderSharingSchedule.java @@ -0,0 +1,40 @@ +package com.iformall.schedule; + +import com.iformall.domain.po.ProductOrder; +import com.iformall.enums.*; +import com.iformall.service.ProductOrderService; +import com.iformall.utils.DateUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import java.util.*; + +@Component +public class ProductOrderSharingSchedule { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Autowired + private ProductOrderService productOrderService; + + @Scheduled(cron = "0 15 2 * * ?") // 每天凌晨02:00分账重试 + public void productOrderSharingSchedule() { + ProductOrder productOrderQ = new ProductOrder(); + productOrderQ.setOrderStatus(EnumProductOrderStatus.ORDER_STATUS_PAYMENT_SUCCESS.getCode()); + productOrderQ.setProfitSharing(EnumProfitSharing.PROFIT_SHARING_MAST.getCode()); + productOrderQ.setPayEndDate(DateUtils.getDateBefore(7,new Date())); + List orderList = productOrderService.findList(productOrderQ); + for (ProductOrder order: orderList) { + try{ + productOrderService.handldSharing(order); + }catch(Exception e){ + logger.error("分账失败:" + e.getMessage()); + } + + } + } + +} \ No newline at end of file diff --git a/suimangService/src/main/java/com/iformall/domain/po/Product.java b/suimangService/src/main/java/com/iformall/domain/po/Product.java new file mode 100644 index 0000000..f6f7afb --- /dev/null +++ b/suimangService/src/main/java/com/iformall/domain/po/Product.java @@ -0,0 +1,56 @@ +package com.iformall.domain.po; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.iformall.domain.po.base.TenantEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import java.util.Date; + +@TableName(value = "product") +@Data +@ToString(callSuper = true) +@EqualsAndHashCode(callSuper = true) +public class Product extends TenantEntity { + + protected Long id; + + @io.swagger.annotations.ApiModelProperty(value="EnumProject",name="projectType") + private Integer projectType; + + @io.swagger.annotations.ApiModelProperty(value="EnumProductType",name="type") + private Integer type; + + @io.swagger.annotations.ApiModelProperty(value="",name="coverImg") + private String coverImg; + @io.swagger.annotations.ApiModelProperty(value="标题",name="title") + private String title; + @io.swagger.annotations.ApiModelProperty(value="",name="enTitle") + private String enTitle; + @io.swagger.annotations.ApiModelProperty(value="金币/积分",name="glod") + private Integer glod; + @io.swagger.annotations.ApiModelProperty(value="",name="detail") + private String detail; + @io.swagger.annotations.ApiModelProperty(value="",name="priceDollar") + private Integer priceDollar; + @io.swagger.annotations.ApiModelProperty(value="",name="sellPriceDollar") + private Integer sellPriceDollar; + @io.swagger.annotations.ApiModelProperty(value="",name="priceRmb") + private Integer priceRmb; + @io.swagger.annotations.ApiModelProperty(value="",name="sellPriceRmb") + private Integer sellPriceRmb; + + @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") + private Date createDate; + @io.swagger.annotations.ApiModelProperty(value="",name="updateDate") + private Date updateDate; + + @TableField(exist = false) + private Date startDate; + + @TableField(exist = false) + private Date endDate; + +} diff --git a/suimangService/src/main/java/com/iformall/domain/po/ProductOrder.java b/suimangService/src/main/java/com/iformall/domain/po/ProductOrder.java new file mode 100644 index 0000000..bb193c5 --- /dev/null +++ b/suimangService/src/main/java/com/iformall/domain/po/ProductOrder.java @@ -0,0 +1,98 @@ +package com.iformall.domain.po; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.iformall.domain.po.base.TenantEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +@TableName(value = "product_order") +@Data +@ToString(callSuper = true) +@EqualsAndHashCode(callSuper = true) +public class ProductOrder extends TenantEntity { + + protected Long id; + + @io.swagger.annotations.ApiModelProperty(value="系统订单号",name="orderNumber") + private String orderNumber; + @io.swagger.annotations.ApiModelProperty(value="用户id",name="userId") + private Long userId; + @io.swagger.annotations.ApiModelProperty(value="产品ID",name="productId") + private Long productId; + @io.swagger.annotations.ApiModelProperty(value="",name="productTitle") + private String productTitle; + @io.swagger.annotations.ApiModelProperty(value="",name="productEnTitle") + private String productEnTitle; + @io.swagger.annotations.ApiModelProperty(value="EnumProductOrderStatus",name="orderStatus") + private Integer orderStatus; + + @io.swagger.annotations.ApiModelProperty(value="EnumProject",name="projectType") + private Integer projectType; + @io.swagger.annotations.ApiModelProperty(value = "EnumProductOrderPayVendor", name = "payVendor") + private Integer payVendor; + + @io.swagger.annotations.ApiModelProperty(value="订单金额(分)",name="orderPrice") + private Integer orderPrice; + @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") + private Date createDate; + @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") + private Date updateDate; + + @io.swagger.annotations.ApiModelProperty(value="",name="remark") + private String remark; + + @io.swagger.annotations.ApiModelProperty(value="支付侧的订单号",name="orderId") + private String orderId; + + @io.swagger.annotations.ApiModelProperty(value="支付者",name="openId") + private String openId; + + @io.swagger.annotations.ApiModelProperty(value="EnumProfitSharing",name="profitSharing") + private Integer profitSharing; + + @io.swagger.annotations.ApiModelProperty(value="支付单号",name="transactionId") + private String transactionId; + + @io.swagger.annotations.ApiModelProperty(value="支付金额(分)",name="payment") + private Integer payment; + @io.swagger.annotations.ApiModelProperty(value="支付时间",name="paymentTime") + private Date paymentTime; + + @io.swagger.annotations.ApiModelProperty(value="支付时间",name="paymentTime") + private Integer payWay; + + + @TableField(exist = false) + protected List statusS; + + @TableField(exist = false) + private String orderPriceStr; + public String getOrderPriceStr() { + return orderPrice != null ? new BigDecimal(orderPrice).divide(new BigDecimal(100)).toPlainString() : orderPriceStr; + } + + @TableField(exist = false) + private String paymentStr; + public String getPaymentStr() { + return payment != null ? new BigDecimal(payment).divide(new BigDecimal(100)).toPlainString() : paymentStr; + } + + @TableField(exist = false) + private Date startDate; + + @TableField(exist = false) + private Date endDate; + + @TableField(exist = false) + private Date payStartDate; + + @TableField(exist = false) + private Date payEndDate; + +} diff --git a/suimangService/src/main/java/com/iformall/domain/po/ProductOrderSharing.java b/suimangService/src/main/java/com/iformall/domain/po/ProductOrderSharing.java new file mode 100644 index 0000000..553817a --- /dev/null +++ b/suimangService/src/main/java/com/iformall/domain/po/ProductOrderSharing.java @@ -0,0 +1,60 @@ +package com.iformall.domain.po; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.iformall.domain.po.base.TenantEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +@TableName(value = "product_order_sharing") +@Data +@EqualsAndHashCode(callSuper = true) +public class ProductOrderSharing extends TenantEntity { + + protected Long id; + + @io.swagger.annotations.ApiModelProperty(value="外部订单号=ProductOrder.orderNumber",name="outOrderId") + private String outOrderId; + + @io.swagger.annotations.ApiModelProperty(value="订单价格",name="orderPrice") + private Integer orderPrice; + + @io.swagger.annotations.ApiModelProperty(value="平台支付单号",name="transactionId") + private String transactionId; + + @io.swagger.annotations.ApiModelProperty(value="EnumProject",name="projectType") + private Integer projectType; + @io.swagger.annotations.ApiModelProperty(value = "EnumProductOrderPayVendor", name = "payVendor") + private Integer payVendor; + + @io.swagger.annotations.ApiModelProperty(value = "外部分账单号", name = "outSettleNo") + private String outSettleNo; + + @io.swagger.annotations.ApiModelProperty(value = "外部分账单号", name = "settleDesc") + private String settleDesc; + + @io.swagger.annotations.ApiModelProperty(value = "平台分账单号", name = "settleNo") + private String settleNo; + + @io.swagger.annotations.ApiModelProperty(value = "分账金额", name = "settleAmount") + private Integer settleAmount; + + @io.swagger.annotations.ApiModelProperty(value = "EnumProductOrderSettleStatus", name = "settleStatus") + private Integer settleStatus; + + @io.swagger.annotations.ApiModelProperty(value="",name="settleDetail") + private String settleDetail; + + + @io.swagger.annotations.ApiModelProperty(value="手续费",name="rake") + private Integer rake; + @io.swagger.annotations.ApiModelProperty(value="佣金",name="commission") + private Integer commission; + + @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") + private Date updateDate; + @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") + private Date createDate; + +} diff --git a/suimangService/src/main/java/com/iformall/domain/po/UserBasicFrom.java b/suimangService/src/main/java/com/iformall/domain/po/UserBasicFrom.java new file mode 100644 index 0000000..4294652 --- /dev/null +++ b/suimangService/src/main/java/com/iformall/domain/po/UserBasicFrom.java @@ -0,0 +1,42 @@ +package com.iformall.domain.po; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.iformall.domain.po.base.TenantEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import java.util.Date; + +@TableName(value = "user_basic_from") +@Data +@ToString(callSuper = true) +@EqualsAndHashCode(callSuper = true) +public class UserBasicFrom extends TenantEntity { + + protected Long id; + + @io.swagger.annotations.ApiModelProperty(value="EnumProject",name="fromProject") + private Integer fromProject; + + @io.swagger.annotations.ApiModelProperty(value="EnumUserBasicFrom",name="fromType") + private Integer fromType; + @io.swagger.annotations.ApiModelProperty(value="邀请途径ID",name="fromId") + private Long fromId; + @io.swagger.annotations.ApiModelProperty(value="邀请人ID",name="fromUserId") + private Long fromUserId; + + @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") + private Date createDate; + + @io.swagger.annotations.ApiModelProperty(value="",name="plat") + private Integer plat; + + @TableField(exist = false) + private Date startDate; + + @TableField(exist = false) + private Date endDate; + +} diff --git a/suimangService/src/main/java/com/iformall/domain/po/UserBasicProperty.java b/suimangService/src/main/java/com/iformall/domain/po/UserBasicProperty.java new file mode 100644 index 0000000..fca841e --- /dev/null +++ b/suimangService/src/main/java/com/iformall/domain/po/UserBasicProperty.java @@ -0,0 +1,30 @@ +package com.iformall.domain.po; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.iformall.domain.po.base.TenantEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import java.util.Date; + +@TableName(value = "user_basic_property") +@Data +@ToString(callSuper = true) +@EqualsAndHashCode(callSuper = true) +public class UserBasicProperty extends TenantEntity { + + protected Long id; + + @io.swagger.annotations.ApiModelProperty(value="数字分身账户",name="digitalAvatarGlod") + private Integer digitalAvatarGlod; + + @io.swagger.annotations.ApiModelProperty(value="数字分身账户余额",name="digitalAvatarResidueGlod") + private Integer digitalAvatarResidueGlod; + + @io.swagger.annotations.ApiModelProperty(value="",name="updateDate") + private Date updateDate; + +} diff --git a/suimangService/src/main/java/com/iformall/domain/po/UserBasicPropertyLog.java b/suimangService/src/main/java/com/iformall/domain/po/UserBasicPropertyLog.java new file mode 100644 index 0000000..9896846 --- /dev/null +++ b/suimangService/src/main/java/com/iformall/domain/po/UserBasicPropertyLog.java @@ -0,0 +1,49 @@ +package com.iformall.domain.po; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.iformall.domain.po.base.TenantEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import java.util.Date; + +@TableName(value = "user_basic_property_log") +@Data +@ToString(callSuper = true) +@EqualsAndHashCode(callSuper = true) +public class UserBasicPropertyLog extends TenantEntity { + + protected Long id; + + @io.swagger.annotations.ApiModelProperty(value="",name="userId") + private Long userId; + + @io.swagger.annotations.ApiModelProperty(value="EnumProject ",name="projectType") + private Integer projectType; + + @io.swagger.annotations.ApiModelProperty(value="EnumPropertyLogType ",name="type") + private Integer type; + + @io.swagger.annotations.ApiModelProperty(value="",name="befourGold") + private Integer befourGold; + + @io.swagger.annotations.ApiModelProperty(value="",name="goldNum") + private Integer goldNum; + + @io.swagger.annotations.ApiModelProperty(value="",name="afterGold") + private Integer afterGold; + + @io.swagger.annotations.ApiModelProperty(value="记录对应的业务ID",name="extraId") + private Long extraId; + + @io.swagger.annotations.ApiModelProperty(value="",name="remark") + private String remark; + + @io.swagger.annotations.ApiModelProperty(value="",name="detail") + private String detail; + + @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") + private Date createDate; + +} diff --git a/suimangService/src/main/java/com/iformall/domain/po/WxAppinfo.java b/suimangService/src/main/java/com/iformall/domain/po/WxAppinfo.java index 2eeea58..20c8afe 100644 --- a/suimangService/src/main/java/com/iformall/domain/po/WxAppinfo.java +++ b/suimangService/src/main/java/com/iformall/domain/po/WxAppinfo.java @@ -36,6 +36,8 @@ public class WxAppinfo extends BaseTenantEntity { private Integer expiresIn; @io.swagger.annotations.ApiModelProperty(value="支付ID,参看wx_pay_account",name="payId") private Long payId; + @io.swagger.annotations.ApiModelProperty(value="EnumProject",name="projectType") + private Integer projectType; @io.swagger.annotations.ApiModelProperty(value="1B端2C端",name="type") private Integer type; @io.swagger.annotations.ApiModelProperty(value="模板类型",name="mouldType") diff --git a/suimangService/src/main/java/com/iformall/douyin/pay/DouYinPayHelper.java b/suimangService/src/main/java/com/iformall/douyin/pay/DouYinPayHelper.java index 586a7cf..9829d33 100644 --- a/suimangService/src/main/java/com/iformall/douyin/pay/DouYinPayHelper.java +++ b/suimangService/src/main/java/com/iformall/douyin/pay/DouYinPayHelper.java @@ -11,6 +11,7 @@ import com.iformall.douyin.pay.orderQuery.QueryRefundResult; import com.iformall.douyin.pay.orderQuery.QuerySettleResult; import com.iformall.douyin.pay.preOrder.*; import com.iformall.enums.EnumPayStatus; +import com.iformall.enums.EnumProductOrderStatus; import com.iformall.exception.MallinkException; import com.iformall.utils.sign.SignUtils; @@ -190,19 +191,19 @@ public class DouYinPayHelper { public static int getPayStatusFromOrderQueryResult(OrderQueryResult result,String payOrderNo) { if(result == null){ - return EnumPayStatus.PAY_STATUS_ORDER_NOT_EXISTS.getCode(); + throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), "订单查询抖音支付状态失败"+payOrderNo); } String orderStatus = result.getOrderStatus(); if(StringUtils.isBlank(orderStatus)){ - return EnumPayStatus.PAY_STATUS_FAIL.getCode(); + return EnumProductOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode(); }else if("PROCESSING".equals(orderStatus)){//以观后效 - return EnumPayStatus.PAY_STATUS_NOTPAY.getCode(); + return EnumProductOrderStatus.ORDER_STATUS_PENDING_PAYMENTING.getCode(); }else if("SUCCESS".equals(orderStatus)){ - return EnumPayStatus.PAY_STATUS_SUCCESS.getCode(); + return EnumProductOrderStatus.ORDER_STATUS_PAYMENT_SUCCESS.getCode(); }else if("FAIL".equals(orderStatus)){ - return EnumPayStatus.PAY_STATUS_FAIL.getCode(); + return EnumProductOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode(); }else if("TIMEOUT".equals(orderStatus)){ - return EnumPayStatus.PAY_STATUS_FAIL.getCode(); + return EnumProductOrderStatus.ORDER_STATUS_OVERTIME_CANCEL.getCode(); } throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), "订单查询抖音支付状态失败"+payOrderNo); } diff --git a/suimangService/src/main/java/com/iformall/enums/EnumProductOrderPayVendor.java b/suimangService/src/main/java/com/iformall/enums/EnumProductOrderPayVendor.java new file mode 100644 index 0000000..8011e66 --- /dev/null +++ b/suimangService/src/main/java/com/iformall/enums/EnumProductOrderPayVendor.java @@ -0,0 +1,51 @@ +package com.iformall.enums; + +/** + * Created by Stormeye on 2018/08/09. + */ +public enum EnumProductOrderPayVendor { + + PAY_WAY_WECHAT(1, "微信小程序",EnumAppPlat.WX.getCode(),EnumProfitSharing.PROFIT_SHARING.getCode()), + PAY_WAY_WECHAT_WAP(2, "微信H5",null,null), + PAY_WAY_ALIPAY(3, "支付宝小程序",null,null), + PAY_WAY_ALIPAY_WAP(4, "支付宝H5",null,null), + PAY_WAY_TT(5, "抖音小程序",EnumAppPlat.TOUTIAO.getCode(),EnumProfitSharing.PROFIT_SHARING_MAST.getCode()), + ; + public static EnumProductOrderPayVendor getEnum(Integer code) { + for (EnumProductOrderPayVendor value : values()) { + if (value.getCode().equals(code)) { + return value; + } + } + return null; + } + + private Integer code; + private String message; + private Integer plat; + private Integer profitSharing; + + EnumProductOrderPayVendor(Integer code, String message, Integer plat, Integer profitSharing) { + this.code = code; + this.message = message; + this.plat = plat; + this.profitSharing = profitSharing; + } + + public Integer getCode() { + return code; + } + + public String getMessage() { + return message; + } + + public Integer getPlat() { + return plat; + } + + public Integer getProfitSharing() { + return profitSharing; + } + +} diff --git a/suimangService/src/main/java/com/iformall/enums/EnumProductOrderSettleStatus.java b/suimangService/src/main/java/com/iformall/enums/EnumProductOrderSettleStatus.java new file mode 100644 index 0000000..92cb1e8 --- /dev/null +++ b/suimangService/src/main/java/com/iformall/enums/EnumProductOrderSettleStatus.java @@ -0,0 +1,38 @@ +package com.iformall.enums; + +/** + * luozukai + */ +public enum EnumProductOrderSettleStatus { + + unfreeze_before(0, "待解冻"), + unfreeze_ing(1, "解冻中"), + unfreeze(2, "已解冻"), + unfreeze_error(3, "解冻失败"), + ; + + public static EnumProductOrderSettleStatus getEnum(Integer code) { + for (EnumProductOrderSettleStatus value : values()) { + if (value.getCode().equals(code)) { + return value; + } + } + return null; + } + + private Integer code; + private String message; + + EnumProductOrderSettleStatus(Integer code, String message) { + this.code = code; + this.message = message; + } + + public Integer getCode() { + return code; + } + + public String getMessage() { + return message; + } +} diff --git a/suimangService/src/main/java/com/iformall/enums/EnumProductOrderStatus.java b/suimangService/src/main/java/com/iformall/enums/EnumProductOrderStatus.java new file mode 100644 index 0000000..b484be2 --- /dev/null +++ b/suimangService/src/main/java/com/iformall/enums/EnumProductOrderStatus.java @@ -0,0 +1,46 @@ +package com.iformall.enums; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by Stormeye on 2018/08/09. + */ +public enum EnumProductOrderStatus { + + // +// ORDER_STATUS_PENDING_CREATE(0, "创建"), + ORDER_STATUS_PENDING_PAYMENT(1, "待支付"), + ORDER_STATUS_PENDING_PAYMENTING(2, "支付中"), + ORDER_STATUS_PAYMENT_SUCCESS(3, "已支付"), + ORDER_STATUS_OVERTIME_CANCEL(4, "已取消"), + ORDER_STATUS_PENDING_REFUND(5,"待退款"), + ORDER_STATUS_REFUND_SUCCESS(6, "已退款"), + ORDER_STATUS_REFUND_FAILD(7, "退款失败"), + ; + public static EnumProductOrderStatus getEnum(Integer code) { + for (EnumProductOrderStatus value : values()) { + if (value.getCode().equals(code)) { + return value; + } + } + return null; + } + + private Integer code; + private String message; + + EnumProductOrderStatus(Integer code, String message) { + this.code = code; + this.message = message; + } + + public Integer getCode() { + return code; + } + + public String getMessage() { + return message; + } + +} diff --git a/suimangService/src/main/java/com/iformall/enums/EnumProductType.java b/suimangService/src/main/java/com/iformall/enums/EnumProductType.java new file mode 100644 index 0000000..2fc7579 --- /dev/null +++ b/suimangService/src/main/java/com/iformall/enums/EnumProductType.java @@ -0,0 +1,52 @@ +package com.iformall.enums; + +import com.iformall.common.ErrorCode; +import com.iformall.exception.MallinkException; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by Stormeye on 2018/08/09. + */ +public enum EnumProductType { + + + product_1(1, "充值金币"), + ; + + public static EnumProductType getEnum(Integer code) { + for (EnumProductType value : values()) { + if (value.getCode().equals(code)) { + return value; + } + } + return null; + } + + public static List getAllCodes(){ + List codes = new ArrayList<>(); + for (EnumProductType value : values()) { + codes.add(value.getCode()); + } + return codes; + } + + private Integer code; + private String message; + + EnumProductType(Integer code, String message) { + this.code = code; + this.message = message; + } + + public Integer getCode() { + return code; + } + + public String getMessage() { + return message; + } + + +} diff --git a/suimangService/src/main/java/com/iformall/enums/EnumProfitSharing.java b/suimangService/src/main/java/com/iformall/enums/EnumProfitSharing.java new file mode 100644 index 0000000..c37682d --- /dev/null +++ b/suimangService/src/main/java/com/iformall/enums/EnumProfitSharing.java @@ -0,0 +1,36 @@ +package com.iformall.enums; + +/** + * Created by Stormeye on 2018/08/09. + */ +public enum EnumProfitSharing { + PROFIT_SHARING(0, "无需分账"), + PROFIT_SHARING_MAST(1, "需要分账"), + PROFIT_SHARING_FINISH(2, "已经分账"), + ; + + public static EnumProfitSharing getEnum(Integer code) { + for (EnumProfitSharing value : values()) { + if (value.getCode().equals(code)) { + return value; + } + } + return null; + } + + private Integer code; + private String message; + + EnumProfitSharing(Integer code, String message) { + this.code = code; + this.message = message; + } + + public Integer getCode() { + return code; + } + + public String getMessage() { + return message; + } +} diff --git a/suimangService/src/main/java/com/iformall/enums/EnumProject.java b/suimangService/src/main/java/com/iformall/enums/EnumProject.java new file mode 100644 index 0000000..acc6dc0 --- /dev/null +++ b/suimangService/src/main/java/com/iformall/enums/EnumProject.java @@ -0,0 +1,41 @@ +package com.iformall.enums; + + +/** + * @author Stormeye + */ + +public enum EnumProject { + + PROJECT_1(1,"邃芒慧播"),//直播 + PROJECT_2(2,"邃芒慧影"),//数字人视频 + PROJECT_3(3,"邃芒慧语"),//照片说话 + PROJECT_4(4,"邃芒慧侃"),//实时对话 + PROJECT_5(5,"邃芒智象"),//数字人分身 + ; + + public static EnumProject getEnum(Integer code) { + for (EnumProject value : values()) { + if (value.getCode().equals(code)) { + return value; + } + } + return null; + } + + private Integer code; + private String message; + + EnumProject(Integer code, String message) { + this.code = code; + this.message = message; + } + + public Integer getCode() { + return code; + } + + public String getMessage() { + return message; + } +} diff --git a/suimangService/src/main/java/com/iformall/enums/EnumPropertyLogType.java b/suimangService/src/main/java/com/iformall/enums/EnumPropertyLogType.java new file mode 100644 index 0000000..e954419 --- /dev/null +++ b/suimangService/src/main/java/com/iformall/enums/EnumPropertyLogType.java @@ -0,0 +1,38 @@ +package com.iformall.enums; + +/** + * Created by Stormeye on 2018/08/09. + */ +public enum EnumPropertyLogType { + + REGISTER(1,"注册"), + INVITE(2,"邀请"), + RECHARGE(3, "充值"), + CONSUMPTION(4, "消费"), + ; + + public static EnumPropertyLogType getEnum(Integer code) { + for (EnumPropertyLogType value : values()) { + if (value.getCode().equals(code)) { + return value; + } + } + return null; + } + + private Integer code; + private String message; + + EnumPropertyLogType(Integer code, String message) { + this.code = code; + this.message = message; + } + + public Integer getCode() { + return code; + } + + public String getMessage() { + return message; + } +} diff --git a/suimangService/src/main/java/com/iformall/enums/EnumUserBasicFrom.java b/suimangService/src/main/java/com/iformall/enums/EnumUserBasicFrom.java new file mode 100644 index 0000000..455c52f --- /dev/null +++ b/suimangService/src/main/java/com/iformall/enums/EnumUserBasicFrom.java @@ -0,0 +1,40 @@ +package com.iformall.enums; + + +/** + * @author Stormeye + */ + +public enum EnumUserBasicFrom { + + FROM_1(1,"系统邀请码"), + FROM_2(2,"会员邀请码"), + FROM_3(3,"会员邀请"),//包括会员二维码邀请,邀请链接 + ; + + public static EnumUserBasicFrom getEnum(Integer code) { + for (EnumUserBasicFrom value : values()) { + if (value.getCode().equals(code)) { + return value; + } + } + return null; + } + + private Integer code; + private String message; + + EnumUserBasicFrom(Integer code, String message) { + this.code = code; + this.message = message; + } + + public Integer getCode() { + return code; + } + + public String getMessage() { + return message; + } + +} diff --git a/suimangService/src/main/java/com/iformall/mapper/ProductMapper.java b/suimangService/src/main/java/com/iformall/mapper/ProductMapper.java new file mode 100644 index 0000000..b0f2fb3 --- /dev/null +++ b/suimangService/src/main/java/com/iformall/mapper/ProductMapper.java @@ -0,0 +1,12 @@ +package com.iformall.mapper; + +import com.iformall.common.CommonMapper; +import com.iformall.domain.po.Product; + +import java.util.List; + +public interface ProductMapper extends CommonMapper{ + + List findList(Product record); + +} diff --git a/suimangService/src/main/java/com/iformall/mapper/ProductOrderMapper.java b/suimangService/src/main/java/com/iformall/mapper/ProductOrderMapper.java new file mode 100644 index 0000000..a0cf472 --- /dev/null +++ b/suimangService/src/main/java/com/iformall/mapper/ProductOrderMapper.java @@ -0,0 +1,13 @@ +package com.iformall.mapper; + +import com.iformall.common.CommonMapper; +import com.iformall.domain.po.ProductOrder; + +import java.util.List; + +public interface ProductOrderMapper extends CommonMapper { + + List findList(ProductOrder record); + + int orderPayUpdStatus(ProductOrder productOrder); +} diff --git a/suimangService/src/main/java/com/iformall/mapper/UserBasicFromMapper.java b/suimangService/src/main/java/com/iformall/mapper/UserBasicFromMapper.java new file mode 100644 index 0000000..4e49821 --- /dev/null +++ b/suimangService/src/main/java/com/iformall/mapper/UserBasicFromMapper.java @@ -0,0 +1,12 @@ +package com.iformall.mapper; + +import com.iformall.common.CommonMapper; +import com.iformall.domain.po.UserBasicFrom; + +import java.util.List; + +public interface UserBasicFromMapper extends CommonMapper{ + + List findList(UserBasicFrom record); + +} diff --git a/suimangService/src/main/java/com/iformall/mapper/UserBasicPropertyLogMapper.java b/suimangService/src/main/java/com/iformall/mapper/UserBasicPropertyLogMapper.java new file mode 100644 index 0000000..14ba9c6 --- /dev/null +++ b/suimangService/src/main/java/com/iformall/mapper/UserBasicPropertyLogMapper.java @@ -0,0 +1,12 @@ +package com.iformall.mapper; + +import com.iformall.common.CommonMapper; +import com.iformall.domain.po.UserBasicPropertyLog; + +import java.util.List; + +public interface UserBasicPropertyLogMapper extends CommonMapper{ + + List findList(UserBasicPropertyLog record); + +} diff --git a/suimangService/src/main/java/com/iformall/mapper/UserBasicPropertyMapper.java b/suimangService/src/main/java/com/iformall/mapper/UserBasicPropertyMapper.java new file mode 100644 index 0000000..6ab56b9 --- /dev/null +++ b/suimangService/src/main/java/com/iformall/mapper/UserBasicPropertyMapper.java @@ -0,0 +1,13 @@ +package com.iformall.mapper; + +import com.iformall.common.CommonMapper; +import com.iformall.domain.po.UserBasicProperty; + +import java.util.List; + +public interface UserBasicPropertyMapper extends CommonMapper{ + + List findList(UserBasicProperty record); + + int addGlod(UserBasicProperty userBasicProperty); +} diff --git a/suimangService/src/main/java/com/iformall/pay/WxPayV3.java b/suimangService/src/main/java/com/iformall/pay/WxPayV3.java index b6aacc8..e4f0062 100644 --- a/suimangService/src/main/java/com/iformall/pay/WxPayV3.java +++ b/suimangService/src/main/java/com/iformall/pay/WxPayV3.java @@ -23,9 +23,7 @@ import com.iformall.service.pay.service.pay.wx.sft.entity.SFTCombineCloseReq; import com.iformall.service.pay.service.pay.wx.sft.entity.SFTCombinePayCommonMiniAppReq; import com.iformall.service.pay.service.pay.wx.sft.entity.SFTPayCommonMiniAppReq; import com.iformall.service.pay.service.pay.wx.sft.entity.SFTPayQueryReq; -import com.iformall.service.pay.service.pay.wx.v3.entity.V3CombinePayCommonMiniAppReq; -import com.iformall.service.pay.service.pay.wx.v3.entity.V3PayCommonMiniAppReq; -import com.iformall.service.pay.service.pay.wx.v3.entity.V3PayQueryReq; +import com.iformall.service.pay.service.pay.wx.v3.entity.*; import com.iformall.service.pay.service.refund.wx.v3.entity.V3PayRefundReq; import com.iformall.service.pay.service.share.wx.v3.entity.V3PayShareQueryReq; import com.iformall.service.pay.service.share.wx.v3.entity.V3PayShareReq; @@ -42,11 +40,17 @@ public class WxPayV3 { private static final String MERCHANT_TRANSFER_CHANGE_URL = "https://api.mch.weixin.qq.com/v3/transfer/batches"; //查询商家转账到零钱 private static final String MERCHANT_TRANSFER_QUERY_URL = "https://api.mch.weixin.qq.com/v3/transfer/batches/out-batch-no/%s"; - + + //小程序下单-(单商户模式) + private static final String PAY_MINIAPP_URL = "https://api.mch.weixin.qq.com/v3/pay/transactions/jsapi"; //小程序下单-普通支付 private static final String PAY_COMMON_MINIAPP_URL = "https://api.mch.weixin.qq.com/v3/pay/partner/transactions/jsapi"; + + //小程序下单-普通支付-查询(单商户模式) + private static final String PAY_QUERY_URL = " https://api.mch.weixin.qq.com/v3/pay/transactions/out-trade-no/%s"; //小程序下单-普通支付-查询 private static final String PAY_COMMON_QUERY_URL = "https://api.mch.weixin.qq.com/v3/pay/partner/transactions/out-trade-no/%s"; + //小程序下单-合单支付 private static final String PAY_COMBINE_MINIAPP_URL = "https://api.mch.weixin.qq.com/v3/combine-transactions/jsapi"; //小程序下单-合单支付-查询 @@ -105,11 +109,6 @@ public class WxPayV3 { * 注意:1. 需要登录到特约商户号自己的商户后台,产品中心---APPID账号管理----我关联的appId账号,把C端小程序关联 * 2. 需要设置白名单IP * 3.微信不能开通运营账户,如果运营账户开通,则资金会从运营账户里面扣取,不会从基本账户扣取 - * @param params - * 请求参数 - * @param certPath - * 证书文件目录 - * @param certPassword * 证书密码 * @return {String} * @throws WxPayException @@ -129,12 +128,6 @@ public class WxPayV3 { /** * 查询商家转账到零钱 * https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter4_3_5.shtml - * @param params - * 请求参数 - * @param certPath - * 证书文件目录 - * @param certPassword - * 证书密码 * @return {String} * @throws WxPayException */ @@ -143,6 +136,14 @@ public class WxPayV3 { param.put("need_query_detail", false); return payService.postV3WithWechatpaySerial(String.format(MERCHANT_TRANSFER_QUERY_URL, batchNo), JSON.toJSONString(param)); } + + /** + * 普通支付-小程序下单 https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_5_1.shtml + * @throws WxPayException + */ + public static String payCommonWithMiniApp(WxPayService payService, V3CreatePayReq payReq) throws WxPayException { + return payService.postV3WithWechatpaySerial(PAY_MINIAPP_URL, JSON.toJSONString(payReq)); + } /** * 普通支付-小程序下单 https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter4_5_1.shtml @@ -151,6 +152,14 @@ public class WxPayV3 { public static String payCommonWithMiniApp(WxPayService payService,V3PayCommonMiniAppReq payReq) throws WxPayException { return payService.postV3WithWechatpaySerial(PAY_COMMON_MINIAPP_URL, JSON.toJSONString(payReq)); } + + /** + * 普通支付-查询https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_5_2.shtml + * @throws WxPayException + */ + public static String payQuery(WxPayService payService, V3PayQuery payQuery) throws WxPayException { + return payService.getV3WithWechatPaySerial(String.format(PAY_QUERY_URL, payQuery.getOut_trade_no())+"?mchid="+payQuery.getMchid()); + } /** * 普通支付-查询https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter4_5_2.shtml diff --git a/suimangService/src/main/java/com/iformall/service/ProductOrderService.java b/suimangService/src/main/java/com/iformall/service/ProductOrderService.java new file mode 100644 index 0000000..1abd1b4 --- /dev/null +++ b/suimangService/src/main/java/com/iformall/service/ProductOrderService.java @@ -0,0 +1,36 @@ +package com.iformall.service; + +import com.github.pagehelper.PageInfo; +import com.iformall.common.ResultData; +import com.iformall.domain.po.*; +import com.iformall.service.pay.service.pay.PayAdapterService; +import com.iformall.service.pay.service.pay.entity.PayQueryAdapterResult; + +import java.util.List; + +public interface ProductOrderService { + + /** + * 根据实体查询分页列表 + * + * @param record + * @param pageIndex + * @param pageSize + * @return + */ + PageInfo listAsPage(ProductOrder record, Integer pageIndex, Integer pageSize); + + void saveOrUpdate(ProductOrder record); + + ProductOrder getById(Long id); + + ResultData createPay(ProductOrder productOrder); + + ResultData handleProductOrderByQuery(WxAppinfo appinfo,WxPayAccount payAccount,ProductOrder productOrder,PayAdapterService payAdapterService); + + void handleProductOrderSuccess(ProductOrder productOrder, PayQueryAdapterResult result); + + List findList(ProductOrder record); + + void handldSharing(ProductOrder order); +} diff --git a/suimangService/src/main/java/com/iformall/service/ProductService.java b/suimangService/src/main/java/com/iformall/service/ProductService.java new file mode 100644 index 0000000..f663f55 --- /dev/null +++ b/suimangService/src/main/java/com/iformall/service/ProductService.java @@ -0,0 +1,19 @@ +package com.iformall.service; + +import com.github.pagehelper.PageInfo; +import com.iformall.domain.po.Product; + +public interface ProductService { + + /** + * 根据实体查询分页列表 + * + * @param record + * @param pageIndex + * @param pageSize + * @return + */ + PageInfo listAsPage(Product record, Integer pageIndex, Integer pageSize); + + Product getById(Long id); +} diff --git a/suimangService/src/main/java/com/iformall/service/UserBasicFromService.java b/suimangService/src/main/java/com/iformall/service/UserBasicFromService.java new file mode 100644 index 0000000..bc20f41 --- /dev/null +++ b/suimangService/src/main/java/com/iformall/service/UserBasicFromService.java @@ -0,0 +1,20 @@ +package com.iformall.service; + +import com.github.pagehelper.PageInfo; +import com.iformall.domain.po.UserBasicFrom; + +public interface UserBasicFromService { + + /** + * 根据实体查询分页列表 + * + * @param record + * @param pageIndex + * @param pageSize + * @return + */ + PageInfo listAsPage(UserBasicFrom record, Integer pageIndex, Integer pageSize); + + void saveForm(UserBasicFrom from); + +} diff --git a/suimangService/src/main/java/com/iformall/service/UserBasicPropertyLogService.java b/suimangService/src/main/java/com/iformall/service/UserBasicPropertyLogService.java new file mode 100644 index 0000000..45847da --- /dev/null +++ b/suimangService/src/main/java/com/iformall/service/UserBasicPropertyLogService.java @@ -0,0 +1,18 @@ +package com.iformall.service; + +import com.github.pagehelper.PageInfo; +import com.iformall.domain.po.UserBasicPropertyLog; + +public interface UserBasicPropertyLogService { + + /** + * 根据实体查询分页列表 + * + * @param record + * @param pageIndex + * @param pageSize + * @return + */ + PageInfo listAsPage(UserBasicPropertyLog record, Integer pageIndex, Integer pageSize); + +} diff --git a/suimangService/src/main/java/com/iformall/service/UserBasicPropertyService.java b/suimangService/src/main/java/com/iformall/service/UserBasicPropertyService.java new file mode 100644 index 0000000..78886ba --- /dev/null +++ b/suimangService/src/main/java/com/iformall/service/UserBasicPropertyService.java @@ -0,0 +1,21 @@ +package com.iformall.service; + +import com.github.pagehelper.PageInfo; +import com.iformall.domain.po.ProductOrder; +import com.iformall.domain.po.UserBasicProperty; + +public interface UserBasicPropertyService { + + /** + * 根据实体查询分页列表 + * + * @param record + * @param pageIndex + * @param pageSize + * @return + */ + PageInfo listAsPage(UserBasicProperty record, Integer pageIndex, Integer pageSize); + + void addRechargeGlod(Long userId, Integer projectType, Long extraId, Integer glod); + +} diff --git a/suimangService/src/main/java/com/iformall/service/WxAppinfoService.java b/suimangService/src/main/java/com/iformall/service/WxAppinfoService.java index fece4aa..7ea31cc 100644 --- a/suimangService/src/main/java/com/iformall/service/WxAppinfoService.java +++ b/suimangService/src/main/java/com/iformall/service/WxAppinfoService.java @@ -7,6 +7,7 @@ import com.iformall.domain.po.WxProjectConfig; import com.iformall.domain.po.base.TenantEntity; import com.iformall.enums.EnumAppPlat; import com.iformall.enums.EnumPayWay; +import com.iformall.enums.EnumProject; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -90,4 +91,8 @@ public interface WxAppinfoService { WxAppinfo getCAppInfoFromRedis(String tenantId, EnumAppPlat appPlat); + WxAppinfo getProjectCAppInfo(Integer projectType, Integer plat); + + WxAppinfo getProjectCAppInfoFromRedis(Integer projectType, Integer plat); + } diff --git a/suimangService/src/main/java/com/iformall/service/cuser/BasicCUserService.java b/suimangService/src/main/java/com/iformall/service/cuser/BasicCUserService.java index 21bd24c..ba5be0a 100644 --- a/suimangService/src/main/java/com/iformall/service/cuser/BasicCUserService.java +++ b/suimangService/src/main/java/com/iformall/service/cuser/BasicCUserService.java @@ -1,6 +1,8 @@ package com.iformall.service.cuser; +import com.iformall.common.ErrorCode; import com.iformall.domain.po.CUser; +import com.iformall.domain.po.UserBasicFrom; import com.iformall.domain.po.WxCUserBasicInfo; import com.iformall.domain.po.WxCUserFrom; import com.iformall.domain.po.base.BaseCUserEntity; @@ -34,6 +36,9 @@ public class BasicCUserService { @Autowired private WxCUserBasicInfoService wxCUserBasicInfoService; + @Autowired + private UserBasicFromService userBasicFromService; + @Autowired private MallCooUserInfoService mallCooUserInfoService; @@ -100,75 +105,31 @@ public class BasicCUserService { cleanCuserToken(user.getToken()); } - public Long saveToBasicInfoByCUser(TenantEntity tenantEntity,String userPhone,String userName,String avatarUrl,Integer sex,Long userId) { - if (StringUtils.isBlank(userPhone)) - return null; - - WxCUserBasicInfo byId = null; - if (null != userId) { - byId = wxCUserBasicInfoService.getById(userId,tenantEntity.getFinalTenantId()); - } + public WxCUserBasicInfo saveToBasicInfoByCUser(CUser cuser, UserBasicFrom from) { - WxCUserBasicInfo basicInfo = wxCUserBasicInfoService.findInfoByPhone(tenantEntity, userPhone); + WxCUserBasicInfo basicInfo = wxCUserBasicInfoService.findInfoByPhone(cuser, cuser.getPhone()); if (basicInfo != null) { - if (byId != null) { - if (!byId.getId().equals(basicInfo.getId())) { - //数据库存在此手机号的会员,并且当前微信存在另一手机号会员 - logger.error("会员" + userId + "更换手机号时,当前手机号会员表已存在:" + userPhone); - return Long.valueOf(-1); - } - } - if (!basicInfo.getTenantId().contains("," + tenantEntity.getTenantId() + ",")) { - basicInfo.setTenantId(basicInfo.getTenantId() + tenantEntity.getTenantId() + ","); - } - basicInfo.setNickName(userName); - basicInfo.setAvatarUrl(avatarUrl); - basicInfo.setSex(sex); + basicInfo.setNickName(cuser.getNickName()); + basicInfo.setAvatarUrl(cuser.getAvatarUrl()); + basicInfo.setSex(cuser.getGender()); wxCUserBasicInfoService.update(basicInfo); - cleanBasicUser(basicInfo.getId()); - return basicInfo.getId(); + return basicInfo; } else { - if (byId != null) { - if (!byId.getTenantId().contains("," + tenantEntity.getTenantId() + ",")) { - byId.setTenantId(byId.getTenantId() + tenantEntity.getTenantId() + ","); - } - byId.setPhone(userPhone); - byId.setNickName(userName); - byId.setAvatarUrl(avatarUrl); - byId.setSex(sex); - wxCUserBasicInfoService.update(byId); - cleanBasicUser(byId.getId()); - return byId.getId(); - } else { - basicInfo = new WxCUserBasicInfo(); - basicInfo.setTenantId("," + tenantEntity.getTenantId() + ","); - basicInfo.setFinalTenantId(tenantEntity.getFinalTenantId()); - basicInfo.setPhone(userPhone); - basicInfo.setNickName(userName); - basicInfo.setAvatarUrl(avatarUrl); - basicInfo.setSex(sex); - wxCUserBasicInfoService.save(basicInfo); - cleanBasicUser(basicInfo.getId()); - - // 首次授权, 增加成长值及积分 - // 成长值 - wxScoreRulesService.addScore(tenantEntity, EnumScoreType.WECHAT_PHONE, basicInfo); - // 增加积分 - wxCUserBasicInfoService.addCredit(basicInfo.getId(),tenantEntity,EnumScoreType.WECHAT_PHONE); - // 外部注券 - memCouponFromDspService.couponOrderFromDsp(tenantEntity, userPhone); - - try{ - //推送猫酷 - mallCooUserInfoService.pullByMobileMsg(tenantEntity, basicInfo.getId()); - }catch(Exception e){ - logger.error("发送同步会员消息异常"); - } - - return basicInfo.getId(); + basicInfo = new WxCUserBasicInfo(); + basicInfo.setPhone(cuser.getNickName()); + basicInfo.setNickName(cuser.getNickName()); + basicInfo.setAvatarUrl(cuser.getNickName()); + basicInfo.setSex(cuser.getGender()); + wxCUserBasicInfoService.save(basicInfo); + + if(from != null){ + from.setId(basicInfo.getId()); + userBasicFromService.saveForm(from); } } + + return basicInfo; } public void setCache(String token,BaseCUserEntity baseUser) { diff --git a/suimangService/src/main/java/com/iformall/service/cuser/CUserServiceApapter.java b/suimangService/src/main/java/com/iformall/service/cuser/CUserServiceApapter.java index 147a3bf..3281ba3 100644 --- a/suimangService/src/main/java/com/iformall/service/cuser/CUserServiceApapter.java +++ b/suimangService/src/main/java/com/iformall/service/cuser/CUserServiceApapter.java @@ -2,9 +2,7 @@ package com.iformall.service.cuser; import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; import com.iformall.domain.dto.WxCUserBasicInfoDto; -import com.iformall.domain.po.CUser; -import com.iformall.domain.po.WxAppinfo; -import com.iformall.domain.po.WxCUserFrom; +import com.iformall.domain.po.*; import com.iformall.domain.po.base.BaseCUserEntity; import com.iformall.domain.po.base.TenantEntity; import com.iformall.domain.vo.UserCountVo; @@ -26,11 +24,11 @@ public interface CUserServiceApapter { void decryptUserInfo(String encryptedData, String iv, CUser cuser, WxAppinfo wxAppinfo, Boolean isFmOpen); - String decryptPhoneNoInfo(String encryptedData, String iv, CUser cuser, WxAppinfo wxAppinfo, boolean isFmOpen); + WxCUserBasicInfo decryptPhoneNoInfo(String encryptedData, String iv, CUser cuser, WxAppinfo wxAppinfo, boolean isFmOpen, UserBasicFrom from); void savePhoneToBasicInfo(CUser user, String phone); - CUser handleLoginUser(CUser cUser, WxCUserFrom wxCUserFrom); + CUser handleLoginUser(CUser cUser); CUser getById(Long id, String tenantId); CUser getByOpenId(String openId, String tenantId); diff --git a/suimangService/src/main/java/com/iformall/service/cuser/tt/TtBUserServiceAdapter.java b/suimangService/src/main/java/com/iformall/service/cuser/tt/TtBUserServiceAdapter.java deleted file mode 100644 index 699edf6..0000000 --- a/suimangService/src/main/java/com/iformall/service/cuser/tt/TtBUserServiceAdapter.java +++ /dev/null @@ -1,283 +0,0 @@ -package com.iformall.service.cuser.tt; - -import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; -import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; -import cn.binarywang.wx.miniapp.bean.WxMaUserInfo; -import com.iformall.common.ErrorCode; -import com.iformall.common.IdWorker; -import com.iformall.domain.dto.WxCUserBasicInfoDto; -import com.iformall.domain.po.*; -import com.iformall.domain.po.base.BaseCUserEntity; -import com.iformall.domain.po.base.TenantEntity; -import com.iformall.domain.vo.UserCountVo; -import com.iformall.domain.vo.UserStructureVo; -import com.iformall.douyin.miniapp.api.TtMaService; -import com.iformall.enums.EnumAppPlat; -import com.iformall.exception.MallinkException; -import com.iformall.mapper.TtBuserMapper; -import com.iformall.service.WxAppinfoService; -import com.iformall.service.cuser.BasicCUserService; -import com.iformall.service.cuser.CUserServiceApapter; -import com.iformall.service.wechat.FmOpenService; -import com.iformall.utils.Constant; -import com.iformall.utils.MaUtil; -import lombok.SneakyThrows; -import me.chanjar.weixin.common.error.WxErrorException; -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.Date; -import java.util.List; - -@Service -public class TtBUserServiceAdapter extends BasicCUserService implements CUserServiceApapter{ - - private final Logger logger = LoggerFactory.getLogger(this.getClass()); - - @Autowired - private WxAppinfoService wxAppinfoService; - - @Autowired - private FmOpenService openService; - - @Autowired - private TtBuserMapper ttBuserMapper; - - @Autowired - MaUtil maUtil; - - private BaseCUserEntity generateBaseEntity(TtBuser ttBuser) { - BaseCUserEntity entity = new BaseCUserEntity(); - entity.setId(ttBuser.getId()); - entity.setExpireTime(ttBuser.getExpireTime()); - entity.setUserId(ttBuser.getUserId()); - entity.setToken(ttBuser.getToken()); - entity.updateTenantInfo(ttBuser); - entity.setAppPlat(EnumAppPlat.TOUTIAO); - WxAppinfo appInfo = wxAppinfoService.getBAppInfo(ttBuser, entity.getAppPlat()); - if (null == appInfo) { - throw new MallinkException(ErrorCode.USER_APPINFO_NOT_EXIST.getCode(), "当前token查询不到APP"); - } - entity.setAppinfo(appInfo); - entity.setRealUser(ttBuser); - return entity; - } - - @Override - public BaseCUserEntity getByToken(String token) { - if ((!StringUtils.isBlank(token))) { - TtBuser ttBuser = ttBuserMapper.findByToken(token); - if (null == ttBuser) { - throw new MallinkException(ErrorCode.NET_TOKEN_INVALID.getCode(), "TtBUserServiceAdapter token失效"); - } - return generateBaseEntity(ttBuser); - }else { - throw new MallinkException(ErrorCode.NET_TOKEN_INVALID.getCode(), "TtBUserServiceAdapter token失效"); - } - } - - @Override - public BaseCUserEntity getByObj(Object buser) { - TtBuser ttBuser = (TtBuser) buser; - return generateBaseEntity(ttBuser); - } - - @SneakyThrows - @Override - public WxMaJscode2SessionResult jsCode2SessionInfo(String code, WxAppinfo wxAppinfo, Boolean isFmOpen) { - TtMaService ttMaService = maUtil.getTtMaService(wxAppinfo); - return ttMaService.jsCode2SessionInfo(code); - } - - @Override - public void decryptUserInfo(String encryptedData, String iv, CUser cuser, WxAppinfo wxAppinfo, Boolean isFmOpen) { - TtMaService ttMaService = maUtil.getTtMaService(wxAppinfo); - WxMaUserInfo userInfo = ttMaService.getUserService().getUserInfo(cuser.getSessionKey(), encryptedData, iv); - if (userInfo != null) { - logger.info("解密用户信息 {}" + userInfo.toString()); - TtBuser updateUser = new TtBuser(); - updateUser.setId(cuser.getId()); - updateUser.updateTenantInfo(cuser); - updateUser.setUnionId(userInfo.getUnionId()); - updateUser.setNickName(userInfo.getNickName()); - updateUser.setGender(Integer.parseInt(userInfo.getGender())); - updateUser.setAvatarUrl(userInfo.getAvatarUrl()); - updateUser.setProvince(userInfo.getProvince()); - updateUser.setCity(userInfo.getCity()); - updateUser.setLanguage(userInfo.getLanguage()); - updateUser.setUpdateDate(new Date()); - ttBuserMapper.updateById(updateUser); - - cleanCuserToken(cuser.getToken()); - } else { - throw new MallinkException(ErrorCode.SYS_BEAN_EMPTY_PROPERTY_ERROR.getCode(), "未获取到用户信息"); - } - } - - @Override - public String decryptPhoneNoInfo(String encryptedData, String iv, CUser cuser, WxAppinfo wxAppinfo, boolean isFmOpen) { - TtMaService ttMaService = maUtil.getTtMaService(wxAppinfo); - WxMaPhoneNumberInfo phoneNoInfo = ttMaService.getUserService().getPhoneNoInfo(cuser.getSessionKey(), encryptedData, iv); - if (null != phoneNoInfo) { - logger.info("解密用户手机号 {}" + phoneNoInfo.toString()); - if(phoneNoInfo.getPhoneNumber().contains("*")){ - throw new MallinkException(ErrorCode.PHONE_IS_ENCRYPTED); - } - TtBuser updateUser = new TtBuser(); - updateUser.setId(cuser.getId()); - updateUser.updateTenantInfo(cuser); - updateUser.setPhone(phoneNoInfo.getPhoneNumber()); - updateUser.setPurePhone(phoneNoInfo.getPurePhoneNumber()); - updateUser.setCountryCode(phoneNoInfo.getCountryCode()); - updateUser.setUpdateDate(new Date()); - ttBuserMapper.updateById(updateUser); - cleanCuserToken(cuser.getToken()); - return updateUser.getPhone(); - } else { - throw new MallinkException(ErrorCode.PHONE_DECODE_ERR); - } - } - - @Override - public void savePhoneToBasicInfo(CUser user, String phone) { - TtBuser updateUser = new TtBuser(); - updateUser.setId(user.getId()); - updateUser.updateTenantInfo(user); - updateUser.setPhone(phone); - updateUser.setUpdateDate(new Date()); - ttBuserMapper.updateById(updateUser); - cleanCuserToken(user.getToken()); - } - - @Override - public CUser handleLoginUser(CUser cUser, WxCUserFrom wxCUserFrom) { - TtBuser newUser = new TtBuser(); - newUser.updateTenantInfo(cUser); - newUser.setAppId(cUser.getAppId()); - newUser.setOpenId(cUser.getOpenId()); - - TtBuser user = ttBuserMapper.findByOpenId(newUser); - - if (user != null) { - // 已有用户 - user.createToken(new Date(),user.getTenantId()); - user.setRegisterIp(cUser.getRegisterIp()); - user.setSessionKey(cUser.getSessionKey()); - user.setUnionId(cUser.getUnionId()); - user.setExtraInfo(cUser.getExtraInfo()); - user.setLoginCount(user.getLoginCount() + 1); - user.setActiveTime(new Date()); - user.setUpdateDate(new Date()); - user.setUserId(cUser.getUserId()); - ttBuserMapper.updateById(user); - } else { - // 新用户 - user = new TtBuser(); - user.updateTenantInfo(cUser); - user.setAppId(cUser.getAppId()); - user.setOpenId(cUser.getOpenId()); - final IdWorker idWorker = IdWorker.get(); - user.setId(idWorker.nextId()); - user.createToken(new Date(),user.getTenantId()); - user.setRegisterIp(cUser.getRegisterIp()); - user.setSessionKey(cUser.getSessionKey()); - user.setUnionId(cUser.getUnionId()); - user.setExtraInfo(cUser.getExtraInfo()); - user.setLoginCount(1); - user.setActiveTime(new Date()); - user.setCreateDate(new Date()); - user.setUpdateDate(new Date()); - user.setUserId(cUser.getUserId()); - ttBuserMapper.insert(user); - - } - updateTokenCache(user.getToken(), user); - return user; - } - - @Override - public CUser getById(Long id, String tenantId) { - return ttBuserMapper.selectById(id); - } - - @Override - public CUser getByOpenId(String openId, String tenantId) { - TtBuser buser = new TtBuser(); - buser.setTenantId(tenantId); - buser.setOpenId(openId); - return ttBuserMapper.findByOpenId(buser); - } - - @Override - public void updateScene(CUser user) { - TtBuser userL = new TtBuser(); - userL.updateTenantInfo(user); - userL.setId(user.getId()); - userL.setScene(user.getScene()); - userL.setUpdateDate(new Date()); - ttBuserMapper.updateById(userL); - cleanCuserToken(user.getToken()); - } - - @Override - public void updateLBS(CUser user) { - TtBuser userL = new TtBuser(); - userL.setId(user.getId()); - userL.updateTenantInfo(user); - userL.setLongitude(user.getLongitude()); - userL.setLatitude(user.getLatitude()); - userL.setUpdateDate(new Date()); - ttBuserMapper.updateById(userL); - cleanCuserToken(user.getToken()); - } - - @Override - public void updateExtInfo(CUser user) { - TtBuser userL = new TtBuser(); - userL.setId(user.getId()); - userL.updateTenantInfo(user); - userL.setExtraInfo(user.getExtraInfo()); - userL.setUpdateDate( new Date()); - ttBuserMapper.updateById(userL); - cleanCuserToken(user.getToken()); - } - - @Override - public void updateMsgCount(CUser user) { - - } - - @Override - public long findCount(WxCUserBasicInfoDto dto) { - return 0l; - } - - @Override - public List findCountHistory(WxCUserBasicInfoDto dto) { - return null; - } - - @Override - public void actionAfterLogin(CUser user) { - - } - - @Override - public String updateQrCode(CUser user) { - return null; - } - - @Override - public List findCountData(WxCUserBasicInfoDto dto) { - return null; - } - - private void updateTokenCache(String token,Object cuser) { - BaseCUserEntity baseUser = this.getByObj(cuser); - setCache(token,baseUser); - } - -} diff --git a/suimangService/src/main/java/com/iformall/service/cuser/tt/TtCUserServiceAdapter.java b/suimangService/src/main/java/com/iformall/service/cuser/tt/TtCUserServiceAdapter.java index f6bd3fb..4c90444 100644 --- a/suimangService/src/main/java/com/iformall/service/cuser/tt/TtCUserServiceAdapter.java +++ b/suimangService/src/main/java/com/iformall/service/cuser/tt/TtCUserServiceAdapter.java @@ -150,10 +150,10 @@ public class TtCUserServiceAdapter extends BasicCUserService implements CUserSer } @Override - public String decryptPhoneNoInfo(String encryptedData, String iv, CUser cuser, WxAppinfo wxAppinfo, boolean isFmOpen) { + public WxCUserBasicInfo decryptPhoneNoInfo(String encryptedData, String iv, CUser cuser, WxAppinfo wxAppinfo, boolean isFmOpen, UserBasicFrom from) { TtMaService ttMaService = maUtil.getTtMaService(wxAppinfo); WxMaPhoneNumberInfo phoneNoInfo = ttMaService.getUserService().getPhoneNoInfo(cuser.getSessionKey(), encryptedData, iv); - if (null != phoneNoInfo) { + if (null != phoneNoInfo && StringUtils.isNotBlank(phoneNoInfo.getPhoneNumber())) { if(phoneNoInfo.getPhoneNumber().contains("*")){ throw new MallinkException(ErrorCode.PHONE_IS_ENCRYPTED); } @@ -163,23 +163,16 @@ public class TtCUserServiceAdapter extends BasicCUserService implements CUserSer updateUser.setPhone(phoneNoInfo.getPhoneNumber()); updateUser.setPurePhone(phoneNoInfo.getPurePhoneNumber()); updateUser.setCountryCode(phoneNoInfo.getCountryCode()); - // 更新到basicinfo - Long userBasicId = saveToBasicInfoByCUser(updateUser,updateUser.getPhone(), cuser.getNickName(), cuser.getAvatarUrl(), cuser.getGender(), cuser.getUserId()); - if (null != userBasicId) { - if(userBasicId.intValue() == -1){ - throw new MallinkException(ErrorCode.USER_PHONE_IS_FOUND); - } - updateUser.setUserId(userBasicId); - }else{ - throw new MallinkException(ErrorCode.PHONE_DECODE_ERR); - } + WxCUserBasicInfo basicInfo = saveToBasicInfoByCUser(updateUser,from); + + updateUser.setUserId(basicInfo.getId()); updateUser.setUpdateDate(new Date()); ttCUserMapper.updateById(updateUser); - delForUserIdOnly(updateUser.getId(),updateUser.getUserId(),updateUser.getTenantId()); - wxCUserTagsService.triggerAssignTags(EnumAssignTagsTrigger.ASSIGN_TAGS_TRIGGER_PHONE, updateUser,updateUser,null); - cleanCuserToken(cuser.getToken()); - return updateUser.getPhone(); + + ttCUserMapper.delForUserIdOnly(updateUser.getId(),updateUser.getUserId(),updateUser.getTenantId()); + + return basicInfo; } else { throw new MallinkException(ErrorCode.PHONE_DECODE_ERR); } @@ -193,24 +186,17 @@ public class TtCUserServiceAdapter extends BasicCUserService implements CUserSer updateUser.setPhone(phone); // 更新到basicinfo - Long userBasicId = saveToBasicInfoByCUser(updateUser,updateUser.getPhone(), user.getNickName(), user.getAvatarUrl(), user.getGender(), user.getUserId()); - if (null != userBasicId) { - if(userBasicId.intValue() == -1){ - throw new MallinkException(ErrorCode.USER_PHONE_IS_FOUND); - } - updateUser.setUserId(userBasicId); - }else{ - throw new MallinkException(ErrorCode.PHONE_DECODE_ERR); - } + WxCUserBasicInfo basicInfo = saveToBasicInfoByCUser(updateUser,null); + + updateUser.setUserId(basicInfo.getId()); updateUser.setUpdateDate(new Date()); ttCUserMapper.updateById(updateUser); - delForUserIdOnly(updateUser.getId(),updateUser.getUserId(),updateUser.getTenantId()); - wxCUserTagsService.triggerAssignTags(EnumAssignTagsTrigger.ASSIGN_TAGS_TRIGGER_PHONE, updateUser,updateUser,null); - cleanCuserToken(user.getToken()); + + ttCUserMapper.delForUserIdOnly(updateUser.getId(),updateUser.getUserId(),updateUser.getTenantId()); } @Override - public CUser handleLoginUser(CUser cUser, WxCUserFrom wxCUserFrom) { + public CUser handleLoginUser(CUser cUser) { TtCUser newUser = new TtCUser(); newUser.updateTenantInfo(cUser); newUser.setAppId(cUser.getAppId()); @@ -229,8 +215,6 @@ public class TtCUserServiceAdapter extends BasicCUserService implements CUserSer user.setActiveTime(new Date()); user.setUpdateDate(new Date()); ttCUserMapper.updateById(user); - - wxCUserFrom.setIsNewUser(EnumYesOrNo.NO.getCode()); } else { user = new TtCUser(); user.setNickName(AppUtils.getAppId());//新用户随机昵称,短8位 @@ -244,19 +228,13 @@ public class TtCUserServiceAdapter extends BasicCUserService implements CUserSer user.setRegisterIp(cUser.getRegisterIp()); user.setSessionKey(cUser.getSessionKey()); user.setUnionId(cUser.getUnionId()); - user.setSceneAddress(wxCUserFrom.getSceneAddress()); - user.setScene(wxCUserFrom.getScene()); user.setExtraInfo(cUser.getExtraInfo()); user.setLoginCount(1); user.setActiveTime(new Date()); user.setCreateDate(new Date()); user.setUpdateDate(new Date()); ttCUserMapper.insert(user); - - wxCUserFrom.setIsNewUser(EnumYesOrNo.YES.getCode()); } - wxCUserFrom.setCUserId(user.getId()); - actionMsgAfterLogin(wxCUserFrom); updateTokenCache(user.getToken(), user); return user; } diff --git a/suimangService/src/main/java/com/iformall/service/cuser/wx/WxBUserServiceAdapter.java b/suimangService/src/main/java/com/iformall/service/cuser/wx/WxBUserServiceAdapter.java deleted file mode 100644 index d66696d..0000000 --- a/suimangService/src/main/java/com/iformall/service/cuser/wx/WxBUserServiceAdapter.java +++ /dev/null @@ -1,328 +0,0 @@ -package com.iformall.service.cuser.wx; - -import cn.binarywang.wx.miniapp.api.WxMaService; -import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; -import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; -import cn.binarywang.wx.miniapp.bean.WxMaUserInfo; -import com.iformall.common.ErrorCode; -import com.iformall.common.IdWorker; -import com.iformall.domain.dto.WxCUserBasicInfoDto; -import com.iformall.domain.po.*; -import com.iformall.domain.po.base.BaseCUserEntity; -import com.iformall.domain.po.base.TenantEntity; -import com.iformall.domain.vo.UserCountVo; -import com.iformall.domain.vo.UserStructureVo; -import com.iformall.enums.EnumAppPlat; -import com.iformall.exception.MallinkException; -import com.iformall.mapper.WxAppinfoMapper; -import com.iformall.mapper.WxBuserMapper; -import com.iformall.service.WxAppinfoService; -import com.iformall.service.cuser.BasicCUserService; -import com.iformall.service.cuser.CUserServiceApapter; -import com.iformall.service.wechat.FmOpenService; -import com.iformall.utils.Constant; -import com.iformall.utils.MaUtil; -import lombok.SneakyThrows; -import me.chanjar.weixin.common.error.WxErrorException; -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.Date; -import java.util.List; - -@Service -public class WxBUserServiceAdapter extends BasicCUserService implements CUserServiceApapter{ - - private final Logger logger = LoggerFactory.getLogger(this.getClass()); - - @Autowired - private WxAppinfoService wxAppinfoService; - - @Autowired - private WxAppinfoMapper wxAppinfoMapper; - - @Autowired - private FmOpenService openService; - - @Autowired - private WxBuserMapper wxBuserMapper; - - @Autowired - MaUtil maUtil; - - private BaseCUserEntity generateBaseEntity(WxBuser wxBuser) { - BaseCUserEntity entity = new BaseCUserEntity(); - entity.setId(wxBuser.getId()); - entity.setExpireTime(wxBuser.getExpireTime()); - entity.setUserId(wxBuser.getUserId()); - entity.setToken(wxBuser.getToken()); - entity.updateTenantInfo(wxBuser); - entity.setAppPlat(EnumAppPlat.WX); - WxAppinfo appInfo = wxAppinfoService.getBAppInfo(wxBuser, entity.getAppPlat()); - if (null == appInfo) { - throw new MallinkException(ErrorCode.USER_APPINFO_NOT_EXIST.getCode(), "当前token查询不到APP"); - } - entity.setAppinfo(appInfo); - entity.setRealUser(wxBuser); - return entity; - } - - @Override - public BaseCUserEntity getByToken(String token) { - if ((!StringUtils.isBlank(token))) { - WxBuser wxBuser = wxBuserMapper.findByToken(token); - if (null == wxBuser) { - throw new MallinkException(ErrorCode.NET_TOKEN_INVALID.getCode(), "WxBUserServiceAdapter token失效"); - } - return generateBaseEntity(wxBuser); - }else { - throw new MallinkException(ErrorCode.NET_TOKEN_INVALID.getCode(), "WxBUserServiceAdapter token失效"); - } - } - - @Override - public BaseCUserEntity getByObj(Object buser) { - WxBuser wxBuser = (WxBuser) buser; - return generateBaseEntity(wxBuser); - } - - @SneakyThrows - @Override - public WxMaJscode2SessionResult jsCode2SessionInfo(String code, WxAppinfo wxAppinfo, Boolean isFmOpen) { - WxMaService wxMaService = this.getWxMaService(wxAppinfo, isFmOpen); - return wxMaService.jsCode2SessionInfo(code); - } - - @Override - public void decryptUserInfo(String encryptedData, String iv, CUser cuser, WxAppinfo wxAppinfo, Boolean isFmOpen) { - WxMaService wxMaService = this.getWxMaService(wxAppinfo, isFmOpen); - WxMaUserInfo userInfo = wxMaService.getUserService().getUserInfo(cuser.getSessionKey(), encryptedData, iv); - if (userInfo != null) { - logger.info("解密用户信息 {}" + userInfo.toString()); - WxBuser updateUser = new WxBuser(); - updateUser.setId(cuser.getId()); - updateUser.updateTenantInfo(cuser); - updateUser.setUnionId(userInfo.getUnionId()); - updateUser.setNickName(userInfo.getNickName()); - updateUser.setGender(Integer.parseInt(userInfo.getGender())); - updateUser.setAvatarUrl(userInfo.getAvatarUrl()); - updateUser.setProvince(userInfo.getProvince()); - updateUser.setCity(userInfo.getCity()); - updateUser.setLanguage(userInfo.getLanguage()); - updateUser.setUpdateDate(new Date()); - wxBuserMapper.updateById(updateUser); - - cleanCuserToken(cuser.getToken()); - } else { - throw new MallinkException(ErrorCode.SYS_BEAN_EMPTY_PROPERTY_ERROR.getCode(), "未获取到用户信息"); - } - } - - @Override - public String decryptPhoneNoInfo(String encryptedData, String iv, CUser cuser, WxAppinfo wxAppinfo, boolean isFmOpen) { - WxMaService wxMaService = this.getWxMaService(wxAppinfo, isFmOpen); - WxMaPhoneNumberInfo phoneNoInfo = wxMaService.getUserService().getPhoneNoInfo(cuser.getSessionKey(), encryptedData, iv); - if (null != phoneNoInfo) { - logger.info("解密用户手机号 {}" + phoneNoInfo.toString()); - if(phoneNoInfo.getPhoneNumber().contains("*")){ - throw new MallinkException(ErrorCode.PHONE_IS_ENCRYPTED); - } - WxBuser updateUser = new WxBuser(); - updateUser.setId(cuser.getId()); - updateUser.updateTenantInfo(cuser); - updateUser.setPhone(phoneNoInfo.getPhoneNumber()); - updateUser.setPurePhone(phoneNoInfo.getPurePhoneNumber()); - updateUser.setCountryCode(phoneNoInfo.getCountryCode()); - updateUser.setUpdateDate(new Date()); - wxBuserMapper.updateById(updateUser); - cleanCuserToken(cuser.getToken()); - return updateUser.getPhone(); - } else { - throw new MallinkException(ErrorCode.PHONE_DECODE_ERR); - } - } - - @Override - public void savePhoneToBasicInfo(CUser user, String phone) { - WxBuser updateUser = new WxBuser(); - updateUser.setId(user.getId()); - updateUser.updateTenantInfo(user); - updateUser.setPhone(phone); - updateUser.setUpdateDate(new Date()); - wxBuserMapper.updateById(updateUser); - cleanCuserToken(user.getToken()); - } - - @Override - public CUser handleLoginUser(CUser cUser, WxCUserFrom wxCUserFrom) { - WxBuser newUser = new WxBuser(); - newUser.updateTenantInfo(cUser); - newUser.setAppId(cUser.getAppId()); - newUser.setOpenId(cUser.getOpenId()); - - WxBuser user = wxBuserMapper.findByOpenId(newUser); - - if (user != null) { - // 已有用户 - user.createToken(new Date(),user.getTenantId()); - user.setRegisterIp(cUser.getRegisterIp()); - user.setSessionKey(cUser.getSessionKey()); - user.setUnionId(cUser.getUnionId()); - user.setExtraInfo(cUser.getExtraInfo()); - user.setLoginCount(user.getLoginCount() + 1); - user.setActiveTime(new Date()); - user.setUpdateDate(new Date()); - user.setUserId(cUser.getUserId()); - wxBuserMapper.updateById(user); - } else { - // 新用户 - user = new WxBuser(); - user.updateTenantInfo(cUser); - user.setAppId(cUser.getAppId()); - user.setOpenId(cUser.getOpenId()); - final IdWorker idWorker = IdWorker.get(); - user.setId(idWorker.nextId()); - user.createToken(new Date(),user.getTenantId()); - user.setRegisterIp(cUser.getRegisterIp()); - user.setSessionKey(cUser.getSessionKey()); - user.setUnionId(cUser.getUnionId()); - user.setExtraInfo(cUser.getExtraInfo()); - user.setLoginCount(1); - user.setActiveTime(new Date()); - user.setCreateDate(new Date()); - user.setUpdateDate(new Date()); - user.setUserId(cUser.getUserId()); - wxBuserMapper.insert(user); - - } - updateTokenCache(user.getToken(), user); - return user; - } - - @Override - public CUser getById(Long id, String tenantId) { - return wxBuserMapper.selectById(id); - } - - @Override - public CUser getByOpenId(String openId, String tenantId) { - WxBuser buser = new WxBuser(); - buser.setTenantId(tenantId); - buser.setOpenId(openId); - return wxBuserMapper.findByOpenId(buser); - } - - @Override - public void updateScene(CUser user) { - WxBuser userL = new WxBuser(); - userL.updateTenantInfo(user); - userL.setId(user.getId()); - userL.setScene(user.getScene()); - userL.setUpdateDate(new Date()); - wxBuserMapper.updateById(userL); - cleanCuserToken(user.getToken()); - } - - @Override - public void updateLBS(CUser user) { - WxBuser userL = new WxBuser(); - userL.setId(user.getId()); - userL.updateTenantInfo(user); - userL.setLongitude(user.getLongitude()); - userL.setLatitude(user.getLatitude()); - userL.setUpdateDate(new Date()); - wxBuserMapper.updateById(userL); - cleanCuserToken(user.getToken()); - } - - @Override - public void updateExtInfo(CUser user) { - WxBuser userL = new WxBuser(); - userL.setId(user.getId()); - userL.updateTenantInfo(user); - userL.setExtraInfo(user.getExtraInfo()); - userL.setUpdateDate( new Date()); - wxBuserMapper.updateById(userL); - cleanCuserToken(user.getToken()); - } - - @Override - public void updateMsgCount(CUser user) { - - } - - @Override - public long findCount(WxCUserBasicInfoDto dto) { - return 0l; - } - - @Override - public List findCountHistory(WxCUserBasicInfoDto dto) { - return null; - } - - @Override - public void actionAfterLogin(CUser user) { - - } - - @Override - public String updateQrCode(CUser user) { - return null; - } - - @Override - public List findCountData(WxCUserBasicInfoDto dto) { - return null; - } - - private WxMaService getWxMaService(WxAppinfo wxAppinfo, Boolean isFmOpen) { - WxMaService wxMaService = null; - if (isFmOpen) { - wxMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(wxAppinfo.getAppId()); - } else { - wxMaService = maUtil.getWeappService(wxAppinfo); - if (StringUtils.isBlank(wxAppinfo.getAccessToken())) { - // 如果没有accessToken,主动获取保存到数据库中,下次访问可以拿来使用 - updateAppAccessToken(wxAppinfo, wxMaService); - - } else { - // 检查token是否已过期, 1小时就重新获取 - Date curDate = new Date(); - if (curDate.getTime() > wxAppinfo.getLastTokenTime().getTime() + Constant.H_EXPIRE) { - updateAppAccessToken(wxAppinfo, wxMaService); - } - } - } - return wxMaService; - } - - private void updateAppAccessToken(WxAppinfo wxAppinfo, WxMaService wxMaService) { - try { - String accessToken = wxMaService.getAccessToken(true); - WxAppinfo updateApp = new WxAppinfo(); - updateApp.setAppId(wxAppinfo.getAppId()); - updateApp.setAccessToken(accessToken); - updateApp.setLastTokenTime(new Date()); - updateApp.setExpiresIn(7200); - wxAppinfo.setAccessToken(updateApp.getAccessToken()); - wxAppinfo.setLastTokenTime(updateApp.getLastTokenTime()); - wxAppinfo.setExpiresIn(updateApp.getExpiresIn()); - wxAppinfoMapper.updateAccessToken(updateApp); - - } catch (WxErrorException e) { - logger.error(e.getMessage()); - } catch (Exception e) { - logger.error(e.getMessage()); - } - } - - private void updateTokenCache(String token,Object cuser) { - BaseCUserEntity baseUser = this.getByObj(cuser); - setCache(token,baseUser); - } - -} diff --git a/suimangService/src/main/java/com/iformall/service/cuser/wx/WxCUserServiceAdapter.java b/suimangService/src/main/java/com/iformall/service/cuser/wx/WxCUserServiceAdapter.java index b2ecbeb..7e74223 100644 --- a/suimangService/src/main/java/com/iformall/service/cuser/wx/WxCUserServiceAdapter.java +++ b/suimangService/src/main/java/com/iformall/service/cuser/wx/WxCUserServiceAdapter.java @@ -162,10 +162,10 @@ public class WxCUserServiceAdapter extends BasicCUserService implements CUserSer } @Override - public String decryptPhoneNoInfo(String encryptedData, String iv, CUser cuser, WxAppinfo wxAppinfo, boolean isFmOpen) { + public WxCUserBasicInfo decryptPhoneNoInfo(String encryptedData, String iv, CUser cuser, WxAppinfo wxAppinfo, boolean isFmOpen, UserBasicFrom from) { WxMaService wxMaService = this.getWxMaService(wxAppinfo, isFmOpen); WxMaPhoneNumberInfo phoneNoInfo = wxMaService.getUserService().getPhoneNoInfo(cuser.getSessionKey(), encryptedData, iv); - if (null != phoneNoInfo) { + if (null != phoneNoInfo && StringUtils.isNotBlank(phoneNoInfo.getPhoneNumber())) { logger.info("解密用户手机号 {}" + phoneNoInfo.toString()); if(phoneNoInfo.getPhoneNumber().contains("*")){ throw new MallinkException(ErrorCode.PHONE_IS_ENCRYPTED); @@ -178,21 +178,14 @@ public class WxCUserServiceAdapter extends BasicCUserService implements CUserSer updateUser.setCountryCode(phoneNoInfo.getCountryCode()); // 更新到basicinfo - Long userBasicId = saveToBasicInfoByCUser(updateUser,updateUser.getPhone(), cuser.getNickName(), cuser.getAvatarUrl(), cuser.getGender(), cuser.getUserId()); - if (null != userBasicId) { - if(userBasicId.intValue() == -1){ - throw new MallinkException(ErrorCode.USER_PHONE_IS_FOUND); - } - updateUser.setUserId(userBasicId); - }else{ - throw new MallinkException(ErrorCode.PHONE_DECODE_ERR); - } + WxCUserBasicInfo basicInfo = saveToBasicInfoByCUser(updateUser,from); + + updateUser.setUserId(basicInfo.getId()); updateUser.setUpdateDate(new Date()); wxCUserMapper.updateById(updateUser); - delForUserIdOnly(updateUser.getId(),updateUser.getUserId(),updateUser.getTenantId()); - wxCUserTagsService.triggerAssignTags(EnumAssignTagsTrigger.ASSIGN_TAGS_TRIGGER_PHONE, updateUser,updateUser,null); - cleanCuserToken(cuser.getToken()); - return updateUser.getPhone(); + + wxCUserMapper.delForUserIdOnly(updateUser.getId(),updateUser.getUserId(),updateUser.getTenantId()); + return basicInfo; } else { throw new MallinkException(ErrorCode.PHONE_DECODE_ERR); } @@ -205,25 +198,17 @@ public class WxCUserServiceAdapter extends BasicCUserService implements CUserSer updateUser.updateTenantInfo(user); updateUser.setPhone(phone); - // 更新到basicinfo - Long userBasicId = saveToBasicInfoByCUser(updateUser,updateUser.getPhone(), user.getNickName(), user.getAvatarUrl(), user.getGender(), user.getUserId()); - if (null != userBasicId) { - if(userBasicId.intValue() == -1){ - throw new MallinkException(ErrorCode.USER_PHONE_IS_FOUND); - } - updateUser.setUserId(userBasicId); - }else{ - throw new MallinkException(ErrorCode.PHONE_DECODE_ERR); - } + WxCUserBasicInfo basicInfo = saveToBasicInfoByCUser(updateUser,null); + + updateUser.setUserId(basicInfo.getId()); updateUser.setUpdateDate(new Date()); wxCUserMapper.updateById(updateUser); - delForUserIdOnly(updateUser.getId(),updateUser.getUserId(),updateUser.getTenantId()); - wxCUserTagsService.triggerAssignTags(EnumAssignTagsTrigger.ASSIGN_TAGS_TRIGGER_PHONE, updateUser,updateUser,null); - cleanCuserToken(user.getToken()); + + wxCUserMapper.delForUserIdOnly(updateUser.getId(),updateUser.getUserId(),updateUser.getTenantId()); } @Override - public CUser handleLoginUser(CUser cUser, WxCUserFrom wxCUserFrom) { + public CUser handleLoginUser(CUser cUser) { WxCUser newUser = new WxCUser(); newUser.updateTenantInfo(cUser); newUser.setAppId(cUser.getAppId()); @@ -231,46 +216,37 @@ public class WxCUserServiceAdapter extends BasicCUserService implements CUserSer WxCUser user = wxCUserMapper.findByOpenId(newUser); + Date now = new Date(); if (user != null) { // 已有用户 user.createToken(new Date(),user.getTenantId()); - user.setRegisterIp(cUser.getRegisterIp()); user.setSessionKey(cUser.getSessionKey()); user.setUnionId(cUser.getUnionId()); user.setExtraInfo(cUser.getExtraInfo()); user.setLoginCount(user.getLoginCount() + 1); - user.setActiveTime(new Date()); - user.setUpdateDate(new Date()); + user.setActiveTime(now); + user.setUpdateDate(now); wxCUserMapper.updateById(user); - - wxCUserFrom.setIsNewUser(EnumYesOrNo.NO.getCode()); } else { // 新用户 user = new WxCUser(); - user.setNickName(AppUtils.getAppId());//新用户随机昵称,短8位 + user.setNickName("未设置昵称"); user.updateTenantInfo(cUser); user.setAppId(cUser.getAppId()); user.setOpenId(cUser.getOpenId()); final IdWorker idWorker = IdWorker.get(); user.setId(idWorker.nextId()); - user.createToken(new Date(),user.getTenantId()); user.setRegisterIp(cUser.getRegisterIp()); user.setSessionKey(cUser.getSessionKey()); user.setUnionId(cUser.getUnionId()); - user.setSceneAddress(wxCUserFrom.getSceneAddress()); - user.setScene(wxCUserFrom.getScene()); user.setExtraInfo(cUser.getExtraInfo()); user.setLoginCount(1); - user.setActiveTime(new Date()); - user.setCreateDate(new Date()); - user.setUpdateDate(new Date()); + user.setActiveTime(now); + user.setCreateDate(now); + user.setUpdateDate(now); + user.createToken(now,user.getTenantId()); wxCUserMapper.insert(user); - - wxCUserFrom.setIsNewUser(EnumYesOrNo.YES.getCode()); } - wxCUserFrom.setCUserId(user.getId()); - actionMsgAfterLogin(wxCUserFrom); - updateTokenCache(user.getToken(), user); return user; } diff --git a/suimangService/src/main/java/com/iformall/service/helper/WxPayOrderServiceHelper.java b/suimangService/src/main/java/com/iformall/service/helper/WxPayOrderServiceHelper.java index 3ee645d..2f94991 100644 --- a/suimangService/src/main/java/com/iformall/service/helper/WxPayOrderServiceHelper.java +++ b/suimangService/src/main/java/com/iformall/service/helper/WxPayOrderServiceHelper.java @@ -72,6 +72,25 @@ public class WxPayOrderServiceHelper { } return null; } + + public static EnumProductOrderStatus getProductOrderStatus(String trade_state) { + if ("SUCCESS".equals(trade_state)) { + return EnumProductOrderStatus.ORDER_STATUS_PAYMENT_SUCCESS; + }else if ("REFUND".equals(trade_state)) { + return EnumProductOrderStatus.ORDER_STATUS_REFUND_SUCCESS; + }else if ("NOTPAY".equals(trade_state)) { + return EnumProductOrderStatus.ORDER_STATUS_PENDING_PAYMENT; + }else if ("CLOSED".equals(trade_state)) { + return EnumProductOrderStatus.ORDER_STATUS_OVERTIME_CANCEL; + }else if ("REVOKED".equals(trade_state)) { + return EnumProductOrderStatus.ORDER_STATUS_PENDING_PAYMENT; + }else if ("USERPAYING".equals(trade_state)) { + return EnumProductOrderStatus.ORDER_STATUS_PENDING_PAYMENTING; + }else if ("PAYERROR".equals(trade_state)) { + return EnumProductOrderStatus.ORDER_STATUS_PENDING_PAYMENT; + } + return null; + } public static int getPayStatusFromMap(Map returnMap,String payOrderNo) { String return_code = returnMap.get("return_code"); diff --git a/suimangService/src/main/java/com/iformall/service/impl/ProductOrderServiceImpl.java b/suimangService/src/main/java/com/iformall/service/impl/ProductOrderServiceImpl.java new file mode 100644 index 0000000..fb4a3ac --- /dev/null +++ b/suimangService/src/main/java/com/iformall/service/impl/ProductOrderServiceImpl.java @@ -0,0 +1,212 @@ +package com.iformall.service.impl; + +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.iformall.common.ErrorCode; +import com.iformall.common.IdWorker; +import com.iformall.common.ResultData; +import com.iformall.domain.po.*; +import com.iformall.enums.EnumProductOrderPayVendor; +import com.iformall.enums.EnumProductOrderStatus; +import com.iformall.enums.EnumProductType; +import com.iformall.exception.MallinkException; +import com.iformall.mapper.ProductMapper; +import com.iformall.mapper.ProductOrderMapper; +import com.iformall.service.ProductOrderService; +import com.iformall.service.UserBasicPropertyService; +import com.iformall.service.WxAppinfoService; +import com.iformall.service.WxPayAccountService; +import com.iformall.service.pay.PayServiceFactory; +import com.iformall.service.pay.service.pay.PayAdapterService; +import com.iformall.service.pay.service.pay.entity.PayAdapterResult; +import com.iformall.service.pay.service.pay.entity.PayQueryAdapterResult; +import com.iformall.service.pay.service.share.PayShareAdapterService; +import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.aop.framework.AopContext; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Date; +import java.util.List; + +@Service +@Slf4j +public class ProductOrderServiceImpl implements ProductOrderService { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Autowired + ProductOrderMapper productOrderMapper; + + @Autowired + ProductMapper productMapper; + + @Autowired + UserBasicPropertyService userBasicPropertyService; + + @Autowired + WxAppinfoService wxAppinfoService; + + @Autowired + WxPayAccountService wxPayAccountService; + + @Autowired + PayServiceFactory payServiceFactory; + + @Override + public PageInfo listAsPage(ProductOrder record, Integer pageIndex, Integer pageSize) { + return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> productOrderMapper.findList(record)); + } + + @Override + public void saveOrUpdate(ProductOrder record) { + Date now = new Date(); + if (record.getId() == null) { + final IdWorker idWorker = IdWorker.get(); + record.setId(idWorker.nextId()); + record.setOrderNumber(record.getId().toString()); + record.setCreateDate(now); + record.setUpdateDate(now); + productOrderMapper.insert(record); + } else { + record.setUpdateDate(now); + productOrderMapper.updateById(record); + } + } + + @Override + public ProductOrder getById(Long id) { + return productOrderMapper.selectById(id); + } + + @Override + public ResultData createPay(ProductOrder productOrder) { + + if(!EnumProductOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode().equals(productOrder.getOrderStatus())){ + return new ResultData(ErrorCode.ORDER_HAD_PAY); + } + + PayAdapterService payAdapterService = payServiceFactory.getPayAdapterService(productOrder.getPayVendor()); + if(payAdapterService == null){ + return new ResultData(ErrorCode.ORDER_IS_NOT_PAY.getCode(),"该订单不支持当前支付"); + } + EnumProductOrderPayVendor payVendoEnum = EnumProductOrderPayVendor.getEnum(productOrder.getPayVendor()); + + WxAppinfo appinfo = wxAppinfoService.getProjectCAppInfoFromRedis(productOrder.getProjectType(), payVendoEnum.getPlat()); + if(appinfo == null){ + return new ResultData(ErrorCode.ORDER_IS_NOT_PAY.getCode(),"未找到支付应用"); + } + WxPayAccount payAccount = wxPayAccountService.getByIdFromRedis(appinfo.getPayId()); + if(payAccount == null){ + return new ResultData(ErrorCode.ORDER_IS_NOT_PAY.getCode(),"未找到支付密钥"); + } + + ResultData resultData = handleProductOrderByQuery(appinfo,payAccount,productOrder,payAdapterService); + if(ResultData.SUCCESS != resultData.code){ + return resultData; + } + if(!EnumProductOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode().equals(productOrder.getOrderStatus())){ + return new ResultData(ErrorCode.ORDER_HAD_PAY); + } + try { + PayAdapterResult payResult = payAdapterService.createPay(productOrder, appinfo, payAccount); + if(payResult.isSuccess()){ + ProductOrder updOrder = new ProductOrder(); + updOrder.setId(productOrder.getId()); + updOrder.setOrderId(payResult.getTransactionId()); + updOrder.setUpdateDate(new Date()); + productOrderMapper.updateById(updOrder); + return new ResultData(payResult.getData()); + }else{ + return new ResultData(ErrorCode.PAY_ORDER_ERROR.getCode(), payResult.getMsg(), payResult.getData()); + } + } catch (Exception e) { + e.printStackTrace(); + return new ResultData(ErrorCode.PAY_ORDER_ERROR.getCode(),"支付订单异常"); + } + } + + @Override + public ResultData handleProductOrderByQuery(WxAppinfo appinfo,WxPayAccount payAccount,ProductOrder productOrder,PayAdapterService payAdapterService) { + + try { + PayQueryAdapterResult result = payAdapterService.queryPayStatus(productOrder, appinfo, payAccount); + Integer productOrderStatus = result.getCode(); + if(productOrderStatus == null){ + return new ResultData(ErrorCode.PAY_ORDER_ERROR.getCode(),"查询支付单异常"); + } + + if(EnumProductOrderStatus.ORDER_STATUS_PAYMENT_SUCCESS.getCode().equals(productOrderStatus)){ + ProductOrderServiceImpl proxy = (ProductOrderServiceImpl) AopContext.currentProxy(); + proxy.handleProductOrderSuccess(productOrder,result); + }else if(EnumProductOrderStatus.ORDER_STATUS_OVERTIME_CANCEL.getCode().equals(productOrderStatus) + || EnumProductOrderStatus.ORDER_STATUS_REFUND_SUCCESS.getCode().equals(productOrderStatus)){ + + productOrder.setOpenId(result.getOpenId()); + productOrder.setTransactionId(result.getTransactionId()); + productOrder.setPaymentTime(result.getPayTime()); + productOrder.setPayWay(result.getWay()); + productOrder.setOrderStatus(productOrderStatus); + productOrder.setUpdateDate(new Date()); + int num = productOrderMapper.orderPayUpdStatus(productOrder); + + }else if(EnumProductOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode().equals(productOrderStatus)){ + + }else{ + return new ResultData(ErrorCode.PAY_ORDER_ERROR.getCode(),"支付单状态异常"); + } + } catch (Exception e) { + e.printStackTrace(); + return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),e.getMessage()); + } + return new ResultData(); + } + + @Override + @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) + public void handleProductOrderSuccess(ProductOrder productOrder, PayQueryAdapterResult result) { + if(!EnumProductOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode().equals(productOrder.getOrderStatus())){ + return; + } + + productOrder.setOpenId(result.getOpenId()); + productOrder.setTransactionId(result.getTransactionId()); + productOrder.setPaymentTime(result.getPayTime()); + productOrder.setPayWay(result.getWay()); + productOrder.setOrderStatus(result.getCode()); + productOrder.setUpdateDate(new Date()); + int num = productOrderMapper.orderPayUpdStatus(productOrder); + if(num == 0){ + return; + }else if(num > 1){ + throw new MallinkException(ErrorCode.ORDER_UPDATE_ERR); + } + Product product = productMapper.selectById(productOrder.getProductId()); + if(EnumProductType.product_1.getCode().equals(product.getType())){ + userBasicPropertyService.addRechargeGlod(productOrder.getUserId(),product.getProjectType(),productOrder.getId(),product.getGlod()); + } + + } + + @Override + public List findList(ProductOrder record) { + return productOrderMapper.findList(record); + } + + @Override + @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) + public void handldSharing(ProductOrder order) { + + + PayShareAdapterService payShareAdapterService = payServiceFactory.getPayShareAdapterService(order.getPayVendor()); + + payShareAdapterService.noReciverShare() + + + } + +} diff --git a/suimangService/src/main/java/com/iformall/service/impl/ProductServiceImpl.java b/suimangService/src/main/java/com/iformall/service/impl/ProductServiceImpl.java new file mode 100644 index 0000000..129fc0e --- /dev/null +++ b/suimangService/src/main/java/com/iformall/service/impl/ProductServiceImpl.java @@ -0,0 +1,35 @@ +package com.iformall.service.impl; + +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.iformall.domain.po.Product; +import com.iformall.mapper.ProductMapper; +import com.iformall.service.ProductService; +import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Date; + +@Service +@Slf4j +public class ProductServiceImpl implements ProductService { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Autowired + ProductMapper productFromMapper; + + @Override + public PageInfo listAsPage(Product record, Integer pageIndex, Integer pageSize) { + return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> productFromMapper.findList(record)); + } + + @Override + public Product getById(Long id) { + return productFromMapper.selectById(id); + } + +} diff --git a/suimangService/src/main/java/com/iformall/service/impl/UserBasicFromServiceImpl.java b/suimangService/src/main/java/com/iformall/service/impl/UserBasicFromServiceImpl.java new file mode 100644 index 0000000..8816bde --- /dev/null +++ b/suimangService/src/main/java/com/iformall/service/impl/UserBasicFromServiceImpl.java @@ -0,0 +1,46 @@ +package com.iformall.service.impl; + +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.iformall.domain.po.UserBasicFrom; +import com.iformall.mapper.UserBasicFromMapper; +import com.iformall.service.UserBasicFromService; +import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Date; + +@Service +@Slf4j +public class UserBasicFromServiceImpl implements UserBasicFromService { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Autowired + UserBasicFromMapper userBasicFromMapper; + + @Override + public PageInfo listAsPage(UserBasicFrom record, Integer pageIndex, Integer pageSize) { + return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> userBasicFromMapper.findList(record)); + } + + @Override + public void saveForm(UserBasicFrom from) { + if(from.getId() == null){ + return; + } + from.setCreateDate(new Date()); + try{ + int insert = userBasicFromMapper.insert(from); + if(insert == 1){ + //todo 邀请逻辑 + + } + }catch(Exception e){} + + } + +} diff --git a/suimangService/src/main/java/com/iformall/service/impl/UserBasicPropertyLogServiceImpl.java b/suimangService/src/main/java/com/iformall/service/impl/UserBasicPropertyLogServiceImpl.java new file mode 100644 index 0000000..95728c3 --- /dev/null +++ b/suimangService/src/main/java/com/iformall/service/impl/UserBasicPropertyLogServiceImpl.java @@ -0,0 +1,29 @@ +package com.iformall.service.impl; + +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.iformall.domain.po.UserBasicPropertyLog; +import com.iformall.mapper.UserBasicPropertyLogMapper; +import com.iformall.service.UserBasicPropertyLogService; +import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +@Slf4j +public class UserBasicPropertyLogServiceImpl implements UserBasicPropertyLogService { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Autowired + UserBasicPropertyLogMapper userBasicPropertyLogMapper; + + @Override + public PageInfo listAsPage(UserBasicPropertyLog record, Integer pageIndex, Integer pageSize) { + return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> userBasicPropertyLogMapper.findList(record)); + } + + +} diff --git a/suimangService/src/main/java/com/iformall/service/impl/UserBasicPropertyServiceImpl.java b/suimangService/src/main/java/com/iformall/service/impl/UserBasicPropertyServiceImpl.java new file mode 100644 index 0000000..b1ba150 --- /dev/null +++ b/suimangService/src/main/java/com/iformall/service/impl/UserBasicPropertyServiceImpl.java @@ -0,0 +1,95 @@ +package com.iformall.service.impl; + +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.iformall.common.ErrorCode; +import com.iformall.common.IdWorker; +import com.iformall.domain.po.*; +import com.iformall.enums.EnumProductOrderStatus; +import com.iformall.enums.EnumProductType; +import com.iformall.enums.EnumProject; +import com.iformall.enums.EnumPropertyLogType; +import com.iformall.exception.MallinkException; +import com.iformall.mapper.ProductMapper; +import com.iformall.mapper.UserBasicPropertyLogMapper; +import com.iformall.mapper.UserBasicPropertyMapper; +import com.iformall.mapper.WxCUserBasicInfoMapper; +import com.iformall.service.UserBasicPropertyService; +import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Date; + +@Service +@Slf4j +public class UserBasicPropertyServiceImpl implements UserBasicPropertyService { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Autowired + UserBasicPropertyMapper userBasicPropertyMapper; + + @Autowired + ProductMapper productMapper; + + @Autowired + WxCUserBasicInfoMapper wxCUserBasicInfoMapper; + + @Autowired + UserBasicPropertyLogMapper userBasicPropertyLogMapper; + + @Override + public PageInfo listAsPage(UserBasicProperty record, Integer pageIndex, Integer pageSize) { + return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> userBasicPropertyMapper.findList(record)); + } + + @Override + @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) + public void addRechargeGlod(Long userId, Integer projectType, Long extraId, Integer glod) { + WxCUserBasicInfo basicInfo = wxCUserBasicInfoMapper.selectById(userId); + if(basicInfo == null){ + throw new MallinkException(ErrorCode.USER_IS_EMPTY); + } + Date now = new Date(); + UserBasicProperty userBasicProperty = userBasicPropertyMapper.selectById(userId); + Integer befourGold = 0; + if(EnumProject.PROJECT_5.getCode().equals(projectType)){ + if(userBasicProperty == null){ + userBasicProperty = new UserBasicProperty(); + userBasicProperty.setId(userId); + userBasicProperty.setDigitalAvatarGlod(glod); + userBasicProperty.setDigitalAvatarResidueGlod(glod); + userBasicProperty.setUpdateDate(now); + userBasicPropertyMapper.insert(userBasicProperty); + }else{ + befourGold = userBasicProperty.getDigitalAvatarResidueGlod(); + + userBasicProperty.setDigitalAvatarGlod(glod); + userBasicProperty.setDigitalAvatarResidueGlod(glod); + userBasicProperty.setUpdateDate(now); + userBasicPropertyMapper.addGlod(userBasicProperty); + } + UserBasicPropertyLog userBasicPropertyLog = new UserBasicPropertyLog(); + final IdWorker idWorker = IdWorker.get(); + userBasicPropertyLog.setId(idWorker.nextId()); + userBasicPropertyLog.setUserId(userId); + userBasicPropertyLog.setProjectType(projectType); + userBasicPropertyLog.setType(EnumPropertyLogType.RECHARGE.getCode()); + userBasicPropertyLog.setBefourGold(befourGold); + userBasicPropertyLog.setGoldNum(glod); + userBasicPropertyLog.setAfterGold(befourGold+glod); + userBasicPropertyLog.setExtraId(extraId); + userBasicPropertyLog.setCreateDate(now); + userBasicPropertyLogMapper.insert(userBasicPropertyLog); + + } + + } + + +} diff --git a/suimangService/src/main/java/com/iformall/service/impl/WxAppinfoServiceImpl.java b/suimangService/src/main/java/com/iformall/service/impl/WxAppinfoServiceImpl.java index a2fd805..bfd6a0e 100644 --- a/suimangService/src/main/java/com/iformall/service/impl/WxAppinfoServiceImpl.java +++ b/suimangService/src/main/java/com/iformall/service/impl/WxAppinfoServiceImpl.java @@ -8,10 +8,7 @@ import com.iformall.domain.po.WxAppinfo; import com.iformall.domain.po.WxCoupon; import com.iformall.domain.po.WxProjectConfig; import com.iformall.domain.po.base.TenantEntity; -import com.iformall.enums.EnumAppPlat; -import com.iformall.enums.EnumAppType; -import com.iformall.enums.EnumCouponType; -import com.iformall.enums.EnumPayWay; +import com.iformall.enums.*; import com.iformall.mapper.WxAppinfoMapper; import com.iformall.service.WxAppinfoService; import com.iformall.service.WxMallService; @@ -239,6 +236,37 @@ public class WxAppinfoServiceImpl implements WxAppinfoService { return record; } + @Override + public WxAppinfo getProjectCAppInfo(Integer projectType, Integer plat) { + if(projectType == null || plat == null){ + return null; + } + WxAppinfo appinfoQ = new WxAppinfo(); + appinfoQ.setProjectType(projectType); + appinfoQ.setPlat(plat); + appinfoQ.setType(EnumAppType.C.getCode()); + WxAppinfo appInfo = wxAppinfoMapper.selectOne(new QueryWrapper<>(appinfoQ)); + return appInfo; + } + + @Override + public WxAppinfo getProjectCAppInfoFromRedis(Integer projectType, Integer plat) { + if(projectType == null || plat == null){ + return null; + } + WxAppinfo record = null; + String key = Constant.appinfoPrev + projectType + "-" + plat + + "-" + EnumAppType.C.getCode(); + record = RedisCacheUtils.getCacheObject(wxAppinfoRedisTemplate, key, WxAppinfo.class); + if (null == record) { + record = this.getProjectCAppInfo(projectType, plat); + if(record != null){ + RedisCacheUtils.cache(wxAppinfoRedisTemplate, key, record, 3600*24*7); + } + } + return record; + } + private void deleteRedis(Long id){ WxAppinfo record = this.getById(id); if(record != null){ diff --git a/suimangService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java b/suimangService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java index 83df171..4abe509 100644 --- a/suimangService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java +++ b/suimangService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java @@ -991,6 +991,7 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService,IExc @Override public void update(WxCUserBasicInfo record) { + record.setUpdateDate(new Date()); wxCUserBasicInfoMapper.updateById(record); } diff --git a/suimangService/src/main/java/com/iformall/service/pay/PayServiceFactory.java b/suimangService/src/main/java/com/iformall/service/pay/PayServiceFactory.java index 8ef7408..56656ba 100644 --- a/suimangService/src/main/java/com/iformall/service/pay/PayServiceFactory.java +++ b/suimangService/src/main/java/com/iformall/service/pay/PayServiceFactory.java @@ -4,6 +4,7 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import com.iformall.enums.EnumAppPlat; import com.iformall.enums.EnumPayVersion; +import com.iformall.enums.EnumProductOrderPayVendor; import com.iformall.service.pay.service.refund.douyin.TtRefundAdapterService; import com.iformall.service.pay.service.refund.wx.v2.WxRefundAdapterService; import com.iformall.service.pay.service.refund.wx.v3.WxRefundV3AdapterService; @@ -45,6 +46,9 @@ public class PayServiceFactory { private Map shareMap = null; private Map refundMap = null; private Map cashoutMap = null; + + private Map payVendorServiceMap = null; + private Map payVendorShareMap = null; @Autowired WxMiniAppPayAdapterService wxMiniAppPayService; @@ -118,6 +122,18 @@ public class PayServiceFactory { } return qrcodeMap; } + + private Map getPayVendorServiceMap() { + if (null == payVendorServiceMap) { + payVendorServiceMap = new ConcurrentHashMap(); + payVendorServiceMap.put(EnumProductOrderPayVendor.PAY_WAY_WECHAT.getCode()+"_", wxMiniAppPayV3AdapterService); + payVendorServiceMap.put(EnumProductOrderPayVendor.PAY_WAY_WECHAT_WAP.getCode()+"_", wxH5PayService); +// payVendorServiceMap.put(EnumProductOrderPayVendor.PAY_WAY_ALIPAY.getCode()+"_", ); +// payVendorServiceMap.put(EnumProductOrderPayVendor.PAY_WAY_ALIPAY_WAP.getCode()+"_",); + payVendorServiceMap.put(EnumProductOrderPayVendor.PAY_WAY_TT.getCode()+"_",ttMiniAppPayService); + } + return payVendorServiceMap; + } private Map getShareMap(){ if (null == shareMap ) { @@ -170,6 +186,18 @@ public class PayServiceFactory { } return shareMap; } + + private Map getPayVendorShareMap(){ + if (null == payVendorShareMap ) { + payVendorShareMap = new ConcurrentHashMap(); + payVendorShareMap.put(EnumProductOrderPayVendor.PAY_WAY_WECHAT.getCode()+"_", wxPayShareV3Service); + payVendorShareMap.put(EnumProductOrderPayVendor.PAY_WAY_WECHAT_WAP.getCode()+"_", null); +// payVendorShareMap.put(EnumProductOrderPayVendor.PAY_WAY_ALIPAY.getCode()+"_", ); +// payVendorShareMap.put(EnumProductOrderPayVendor.PAY_WAY_ALIPAY_WAP.getCode()+"_",); + payVendorShareMap.put(EnumProductOrderPayVendor.PAY_WAY_TT.getCode()+"_",ttShareService); + } + return payVendorShareMap; + } private Map getRefundMap(){ if (null == refundMap ) { @@ -202,6 +230,14 @@ public class PayServiceFactory { return service; } + public PayAdapterService getPayAdapterService(Integer payVendor) throws MallinkException{ + PayAdapterService service = getPayVendorServiceMap().get(payVendor+"_"); + if (null == service) { + throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"payWay["+payVendor+"] 支付service未找到"); + } + return service; + } + public PayAdapterService getQrcodeService(Integer type,Integer payVersion) throws MallinkException{ PayAdapterService service = getQrcodeMap().get(type+"_"+payVersion); if (null == service) { @@ -241,6 +277,14 @@ public class PayServiceFactory { } return shareService; } + + public PayShareAdapterService getPayShareAdapterService(Integer payVendor) throws MallinkException{ + PayShareAdapterService shareService = getPayVendorShareMap().get(payVendor+"_"); + if (null == shareService) { + throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"payWay["+payVendor+"] 分账service未找到"); + } + return shareService; + } public RefundPayAdapterService getRefundPayAdapterService(Integer type,Integer payVersion) throws MallinkException{ RefundPayAdapterService refundService = getRefundMap().get(type+"_"+payVersion); diff --git a/suimangService/src/main/java/com/iformall/service/pay/service/pay/PayAdapterService.java b/suimangService/src/main/java/com/iformall/service/pay/service/pay/PayAdapterService.java index b574875..22bb558 100644 --- a/suimangService/src/main/java/com/iformall/service/pay/service/pay/PayAdapterService.java +++ b/suimangService/src/main/java/com/iformall/service/pay/service/pay/PayAdapterService.java @@ -29,6 +29,15 @@ public interface PayAdapterService { */ public PayAdapterResult pay(WxPayAccount payAccount,WxPayOrder record ,WxComposeOrder composeOrder,List childOrders,String productName,EnumPayShare isShare,WxAppinfo appInfo,Date currentDate, PayExtraParam params) throws Exception; + /** + * 真正支付过程,调用对应端的API调用支付 + * @param payAccount WxPayAccount + * @param order ProductOrder + * @param appInfo C端app + * @throws Exception + */ + public PayAdapterResult createPay(ProductOrder order,WxAppinfo appInfo,WxPayAccount payAccount) throws Exception; + /** * 查询支付结果,调用对应端的API查询支付结果 * @param oldRecord WxPayOrder @@ -39,6 +48,8 @@ public interface PayAdapterService { * @throws Exception */ public PayQueryAdapterResult queryPayStatus(WxPayOrder oldRecord,WxAppinfo appInfo,WxPayAccount payAccount) throws Exception; + + public PayQueryAdapterResult queryPayStatus(ProductOrder order,WxAppinfo appInfo,WxPayAccount payAccount) throws Exception; /** * 根据返回结果对象解析出支付状态 diff --git a/suimangService/src/main/java/com/iformall/service/pay/service/pay/douyin/v1/miniApp/TtMiniAppPayAdapterService.java b/suimangService/src/main/java/com/iformall/service/pay/service/pay/douyin/v1/miniApp/TtMiniAppPayAdapterService.java index ded167a..a674798 100644 --- a/suimangService/src/main/java/com/iformall/service/pay/service/pay/douyin/v1/miniApp/TtMiniAppPayAdapterService.java +++ b/suimangService/src/main/java/com/iformall/service/pay/service/pay/douyin/v1/miniApp/TtMiniAppPayAdapterService.java @@ -11,6 +11,7 @@ import com.iformall.domain.vo.WxOrderCouponVo; import com.iformall.douyin.miniapp.api.TtMaService; import com.iformall.douyin.pay.DouYinPayHelper; import com.iformall.douyin.pay.TtPayService; +import com.iformall.douyin.pay.orderQuery.OrderQueryResult; import com.iformall.douyin.pay.preOrder.CreatePreOrderResult; import com.iformall.douyin.pay.preOrder.DouYinCreatePreOrder; import com.iformall.douyin.payv2.request.TtPayUnifiedOrderV2Request; @@ -19,6 +20,7 @@ import com.iformall.enums.*; import com.iformall.exception.MallinkException; import com.iformall.mapper.*; import com.iformall.service.WxCouponService; +import com.iformall.service.helper.WxPayOrderServiceHelper; import com.iformall.service.order.OrderAdapterService; import com.iformall.service.order.OrderFactory; import com.iformall.service.order.entity.WxComposeChildOrderShare; @@ -221,12 +223,52 @@ public class TtMiniAppPayAdapterService extends BaseTtPayAdapterService implemen // return par; } + @Override + public PayAdapterResult createPay(ProductOrder order, WxAppinfo appInfo, WxPayAccount payAccount) throws Exception { + + DouYinCreatePreOrder preOrder = new DouYinCreatePreOrder(); + preOrder.setAppId(appInfo.getAppId()); + preOrder.setSercrect(appInfo.getSecret()); + preOrder.setSalt(payAccount.getApiKey()); + preOrder.setOutOrderNo(order.getOrderNumber()); + preOrder.setTotalAmount(order.getOrderPrice()); + preOrder.setSubject(appInfo.getName()+"-"+order.getProductTitle()); + preOrder.setBody(appInfo.getName()+"-"+order.getProductTitle()); + preOrder.setValidTime(30*60); +// preOrder.setNotifyUrl();//回调地址 +// preOrder.setThirdpartyId();//第三方服务商ID +// preOrder.setStoreId(record.getStoreId()); + CreatePreOrderResult preOrderResult = DouYinPayHelper.createPreOrder(preOrder); + + PayAdapterResult par = new PayAdapterResult(); + par.setSuccess(preOrderResult.isSuccess()); + par.setMsg(preOrderResult.getMsg()); + par.setTransactionId(preOrderResult.getOrderId()); + par.setData(preOrderResult); + return par; + } + @Override public PayQueryAdapterResult queryPayStatus(WxPayOrder oldRecord, WxAppinfo appInfo, WxPayAccount payAccount) throws Exception { return super.queryPayStatus(oldRecord,appInfo, payAccount); } + @Override + public PayQueryAdapterResult queryPayStatus(ProductOrder order, WxAppinfo appInfo, WxPayAccount payAccount) throws Exception { + OrderQueryResult orderQueryResult = DouYinPayHelper.orderQuery(appInfo.getAppId(), payAccount.getApiKey(), order.getOrderNumber(), null); + int code = DouYinPayHelper.getPayStatusFromOrderQueryResult(orderQueryResult,order.getOrderNumber()); + PayQueryAdapterResult result = new PayQueryAdapterResult(); + result.setCode(code); + result.setMsg(EnumProductOrderStatus.getEnum(code).getMessage()); + result.setTransactionId(orderQueryResult.getChannelNo()); + result.setWay(orderQueryResult.getWay()); + if(StringUtils.isNotBlank(orderQueryResult.getPayTime())){ + result.setPayTime(DateUtils.stringToDate(orderQueryResult.getPayTime(),DateUtils.DATE_TIME_PATTERN)); + } + return result; + } + @Override public int queryPayStatus(PayQueryAdapterResult statusObject, String orderOutNo) throws Exception { return super.queryPayStatus(statusObject, orderOutNo); diff --git a/suimangService/src/main/java/com/iformall/service/pay/service/pay/entity/PayQueryAdapterResult.java b/suimangService/src/main/java/com/iformall/service/pay/service/pay/entity/PayQueryAdapterResult.java index 4f41c3f..bc1ff8c 100644 --- a/suimangService/src/main/java/com/iformall/service/pay/service/pay/entity/PayQueryAdapterResult.java +++ b/suimangService/src/main/java/com/iformall/service/pay/service/pay/entity/PayQueryAdapterResult.java @@ -1,6 +1,7 @@ package com.iformall.service.pay.service.pay.entity; import java.io.Serializable; +import java.util.Date; import lombok.Data; import lombok.ToString; @@ -10,8 +11,10 @@ import lombok.ToString; public class PayQueryAdapterResult implements Serializable{ private static final long serialVersionUID = -8271349001408799798L; + + public PayQueryAdapterResult(){} - public PayQueryAdapterResult(int code, String msg, Integer way, Object data,String transactionId,String endTimeStr) { + public PayQueryAdapterResult(Integer code, String msg, Integer way, Object data,String transactionId,String endTimeStr) { this.code = code; this.msg = msg; this.way = way; @@ -20,16 +23,22 @@ public class PayQueryAdapterResult implements Serializable{ this.endTimeStr = endTimeStr; } - private int code; + private Integer code; - private Integer way; - private String msg; + + //抖音支付方式 + private Integer way; private Object data; - + + //支付订单号 private String transactionId; - + + private String openId; + + //支付时间 + private Date payTime; private String endTimeStr; } diff --git a/suimangService/src/main/java/com/iformall/service/pay/service/pay/wx/sft/h5/WxH5PaySFTService.java b/suimangService/src/main/java/com/iformall/service/pay/service/pay/wx/sft/h5/WxH5PaySFTService.java index b611256..1a9bcb0 100644 --- a/suimangService/src/main/java/com/iformall/service/pay/service/pay/wx/sft/h5/WxH5PaySFTService.java +++ b/suimangService/src/main/java/com/iformall/service/pay/service/pay/wx/sft/h5/WxH5PaySFTService.java @@ -29,6 +29,11 @@ public class WxH5PaySFTService extends BaseWxPaySFTAdapterService implements CDr return null; } + @Override + public PayAdapterResult createPay(ProductOrder order, WxAppinfo appInfo, WxPayAccount payAccount) throws Exception { + return null; + } + @Override public PayQueryAdapterResult queryPayStatus(WxPayOrder oldRecord, WxAppinfo appInfo, WxPayAccount payAccount) throws Exception { @@ -36,6 +41,11 @@ public class WxH5PaySFTService extends BaseWxPaySFTAdapterService implements CDr return null; } + @Override + public PayQueryAdapterResult queryPayStatus(ProductOrder order, WxAppinfo appInfo, WxPayAccount payAccount) throws Exception { + return null; + } + @Override public int queryPayStatus(PayQueryAdapterResult statusObject, String orderOutNo) throws Exception { //return super.queryPayStatus(statusObject, orderOutNo); diff --git a/suimangService/src/main/java/com/iformall/service/pay/service/pay/wx/sft/miniApp/appPay/WxMiniAppPaySFTAdapterService.java b/suimangService/src/main/java/com/iformall/service/pay/service/pay/wx/sft/miniApp/appPay/WxMiniAppPaySFTAdapterService.java index d23d65c..3895606 100644 --- a/suimangService/src/main/java/com/iformall/service/pay/service/pay/wx/sft/miniApp/appPay/WxMiniAppPaySFTAdapterService.java +++ b/suimangService/src/main/java/com/iformall/service/pay/service/pay/wx/sft/miniApp/appPay/WxMiniAppPaySFTAdapterService.java @@ -193,7 +193,12 @@ public class WxMiniAppPaySFTAdapterService extends BaseWxPaySFTAdapterService i // return getOrderPResult(response); } } - + + @Override + public PayAdapterResult createPay(ProductOrder order, WxAppinfo appInfo, WxPayAccount payAccount) throws Exception { + return null; + } + private PayQueryAdapterResult getPayCommonQueryResult(String response) { JSONObject result = JSON.parseObject(response); String transtionId = result.getString("transaction_id"); @@ -261,6 +266,11 @@ public class WxMiniAppPaySFTAdapterService extends BaseWxPaySFTAdapterService i } } + @Override + public PayQueryAdapterResult queryPayStatus(ProductOrder order, WxAppinfo appInfo, WxPayAccount payAccount) throws Exception { + return null; + } + @Override public int queryPayStatus(PayQueryAdapterResult statusObject, String orderOutNo) throws Exception { return getPayCommonQueryResult((String)statusObject.getData()).getCode(); diff --git a/suimangService/src/main/java/com/iformall/service/pay/service/pay/wx/v2/h5/WxH5PayService.java b/suimangService/src/main/java/com/iformall/service/pay/service/pay/wx/v2/h5/WxH5PayService.java index baeb391..a2c2902 100644 --- a/suimangService/src/main/java/com/iformall/service/pay/service/pay/wx/v2/h5/WxH5PayService.java +++ b/suimangService/src/main/java/com/iformall/service/pay/service/pay/wx/v2/h5/WxH5PayService.java @@ -28,12 +28,22 @@ public class WxH5PayService extends BaseWxPayV2AdapterService implements CDrivi return null; } + @Override + public PayAdapterResult createPay(ProductOrder order, WxAppinfo appInfo, WxPayAccount payAccount) throws Exception { + return null; + } + @Override public PayQueryAdapterResult queryPayStatus(WxPayOrder oldRecord, WxAppinfo appInfo, WxPayAccount payAccount) throws Exception { return super.queryPayStatus(oldRecord, appInfo, payAccount); } + @Override + public PayQueryAdapterResult queryPayStatus(ProductOrder order, WxAppinfo appInfo, WxPayAccount payAccount) throws Exception { + return null; + } + @Override public int queryPayStatus(PayQueryAdapterResult statusObject, String orderOutNo) throws Exception { return super.queryPayStatus(statusObject, orderOutNo); diff --git a/suimangService/src/main/java/com/iformall/service/pay/service/pay/wx/v2/miniApp/appPay/WxMiniAppPayAdapterService.java b/suimangService/src/main/java/com/iformall/service/pay/service/pay/wx/v2/miniApp/appPay/WxMiniAppPayAdapterService.java index 0438b5b..b01ef51 100644 --- a/suimangService/src/main/java/com/iformall/service/pay/service/pay/wx/v2/miniApp/appPay/WxMiniAppPayAdapterService.java +++ b/suimangService/src/main/java/com/iformall/service/pay/service/pay/wx/v2/miniApp/appPay/WxMiniAppPayAdapterService.java @@ -248,13 +248,23 @@ public class WxMiniAppPayAdapterService extends BaseWxPayV2AdapterService implem } } - @Override + @Override + public PayAdapterResult createPay(ProductOrder order, WxAppinfo appInfo, WxPayAccount payAccount) throws Exception { + return null; + } + + @Override public PayQueryAdapterResult queryPayStatus(WxPayOrder oldRecord, WxAppinfo appInfo, WxPayAccount payAccount) throws Exception { return super.queryPayStatus(oldRecord,appInfo, payAccount); } - @Override + @Override + public PayQueryAdapterResult queryPayStatus(ProductOrder order, WxAppinfo appInfo, WxPayAccount payAccount) throws Exception { + return null; + } + + @Override public int queryPayStatus(PayQueryAdapterResult statusObject, String orderOutNo) throws Exception { return super.queryPayStatus(statusObject, orderOutNo); } diff --git a/suimangService/src/main/java/com/iformall/service/pay/service/pay/wx/v2/miniApp/maPay/WxMiniMaPayAdapterService.java b/suimangService/src/main/java/com/iformall/service/pay/service/pay/wx/v2/miniApp/maPay/WxMiniMaPayAdapterService.java index 2969397..119c142 100644 --- a/suimangService/src/main/java/com/iformall/service/pay/service/pay/wx/v2/miniApp/maPay/WxMiniMaPayAdapterService.java +++ b/suimangService/src/main/java/com/iformall/service/pay/service/pay/wx/v2/miniApp/maPay/WxMiniMaPayAdapterService.java @@ -216,8 +216,13 @@ public class WxMiniMaPayAdapterService extends BaseWxPayV2AdapterService impleme } } - - @Autowired + @Override + public PayAdapterResult createPay(ProductOrder order, WxAppinfo appInfo, WxPayAccount payAccount) throws Exception { + return null; + } + + + @Autowired WxCUserMapper wxCUserMapper; @Autowired WxCUserService wxCUserService; @@ -250,7 +255,12 @@ public class WxMiniMaPayAdapterService extends BaseWxPayV2AdapterService impleme return super.queryPayStatus(oldRecord,appInfo, payAccount); } - @Override + @Override + public PayQueryAdapterResult queryPayStatus(ProductOrder order, WxAppinfo appInfo, WxPayAccount payAccount) throws Exception { + return null; + } + + @Override public int queryPayStatus(PayQueryAdapterResult statusObject, String orderOutNo) throws Exception { return super.queryPayStatus(statusObject, orderOutNo); } diff --git a/suimangService/src/main/java/com/iformall/service/pay/service/pay/wx/v3/entity/V3CreatePayReq.java b/suimangService/src/main/java/com/iformall/service/pay/service/pay/wx/v3/entity/V3CreatePayReq.java new file mode 100644 index 0000000..803dc49 --- /dev/null +++ b/suimangService/src/main/java/com/iformall/service/pay/service/pay/wx/v3/entity/V3CreatePayReq.java @@ -0,0 +1,17 @@ +package com.iformall.service.pay.service.pay.wx.v3.entity; + +import lombok.Data; + +@Data +public class V3CreatePayReq { + + private String appid;// + private String mchid;// + private String description;//商品描述 + private String out_trade_no;//商户订单号 + private String attach;//附加数据,在查询API和支付通知中原样返回,可作为自定义参数使用,实际情况下只有支付完成状态才会返回该字段。 + private String notify_url;//通知地址,不允许携带查询串 + private V3PaySettleReq settle_info;//结算信息 + private V3PayAmountReq amount;//订单金额 + private V3Payer payer;//支付者 +} diff --git a/suimangService/src/main/java/com/iformall/service/pay/service/pay/wx/v3/entity/V3PayQuery.java b/suimangService/src/main/java/com/iformall/service/pay/service/pay/wx/v3/entity/V3PayQuery.java new file mode 100644 index 0000000..703470f --- /dev/null +++ b/suimangService/src/main/java/com/iformall/service/pay/service/pay/wx/v3/entity/V3PayQuery.java @@ -0,0 +1,13 @@ +package com.iformall.service.pay.service.pay.wx.v3.entity; + +import com.alibaba.fastjson.annotation.JSONField; +import lombok.Data; + +@Data +public class V3PayQuery { + + private String mchid; + + private String out_trade_no;//商户订单号 + +} diff --git a/suimangService/src/main/java/com/iformall/service/pay/service/pay/wx/v3/entity/V3Payer.java b/suimangService/src/main/java/com/iformall/service/pay/service/pay/wx/v3/entity/V3Payer.java new file mode 100644 index 0000000..e96142b --- /dev/null +++ b/suimangService/src/main/java/com/iformall/service/pay/service/pay/wx/v3/entity/V3Payer.java @@ -0,0 +1,10 @@ +package com.iformall.service.pay.service.pay.wx.v3.entity; + +import lombok.Data; + +@Data +public class V3Payer { + + private String openid;//用户在子商户appid下的唯一标识 + +} diff --git a/suimangService/src/main/java/com/iformall/service/pay/service/pay/wx/v3/miniApp/appPay/WxMiniAppPayV3AdapterService.java b/suimangService/src/main/java/com/iformall/service/pay/service/pay/wx/v3/miniApp/appPay/WxMiniAppPayV3AdapterService.java index 0cb39b0..fbb79f7 100644 --- a/suimangService/src/main/java/com/iformall/service/pay/service/pay/wx/v3/miniApp/appPay/WxMiniAppPayV3AdapterService.java +++ b/suimangService/src/main/java/com/iformall/service/pay/service/pay/wx/v3/miniApp/appPay/WxMiniAppPayV3AdapterService.java @@ -9,6 +9,9 @@ import java.util.List; import java.util.Map; import com.iformall.domain.po.*; +import com.iformall.enums.*; +import com.iformall.service.pay.service.pay.wx.v3.entity.*; +import com.iformall.utils.*; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -21,11 +24,6 @@ import com.github.binarywang.wxpay.service.WxPayService; import com.iformall.common.ErrorCode; import com.iformall.common.Result; import com.iformall.common.ResultData; -import com.iformall.enums.EnumOrderStatus; -import com.iformall.enums.EnumPayMchType; -import com.iformall.enums.EnumPayMode; -import com.iformall.enums.EnumPayShare; -import com.iformall.enums.EnumPayStatus; import com.iformall.exception.MallinkException; import com.iformall.pay.WxPay; import com.iformall.pay.WxPayOrderP; @@ -49,18 +47,6 @@ import com.iformall.service.pay.service.pay.wx.sft.entity.SFTPaySettleReq; import com.iformall.service.pay.service.pay.wx.sft.entity.SFTPayerReq; import com.iformall.service.pay.service.pay.wx.v2.BaseWxPayV2AdapterService; import com.iformall.service.pay.service.pay.wx.v3.BaseWxPayV3AdapterService; -import com.iformall.service.pay.service.pay.wx.v3.entity.V3CombineItemOrder; -import com.iformall.service.pay.service.pay.wx.v3.entity.V3CombinePayCommonMiniAppReq; -import com.iformall.service.pay.service.pay.wx.v3.entity.V3CombinePayerReq; -import com.iformall.service.pay.service.pay.wx.v3.entity.V3PayAmountReq; -import com.iformall.service.pay.service.pay.wx.v3.entity.V3PayCommonMiniAppReq; -import com.iformall.service.pay.service.pay.wx.v3.entity.V3PayQueryReq; -import com.iformall.service.pay.service.pay.wx.v3.entity.V3PaySettleReq; -import com.iformall.service.pay.service.pay.wx.v3.entity.V3PayerReq; -import com.iformall.utils.BeanUtils; -import com.iformall.utils.MaUtil; -import com.iformall.utils.MapUtil; -import com.iformall.utils.Utility; import lombok.extern.slf4j.Slf4j; @@ -109,8 +95,32 @@ public class WxMiniAppPayV3AdapterService extends BaseWxPayV3AdapterService impl return req; } + + private V3CreatePayReq generateCreatePayRequest(ProductOrder productOrder,WxAppinfo appInfo,WxPayAccount payAccount) throws Exception { + V3CreatePayReq req = new V3CreatePayReq(); + req.setAppid(appInfo.getAppId()); + req.setMchid(payAccount.getMchId()); + try { + //中文必须要这样,否则会双方签名失败 + req.setDescription(WxPayV3.handleChinese(appInfo.getName()+"-"+productOrder.getProductTitle())); + } catch (UnsupportedEncodingException e) { + req.setDescription("weixin miniApp product"); + } + req.setOut_trade_no(productOrder.getOrderNumber()); + req.setNotify_url(payAccount.getPayNotifyV3Url()); + + V3PayAmountReq amout = new V3PayAmountReq(); + amout.setTotal(productOrder.getOrderPrice()); + req.setAmount(amout); + + V3Payer payer = new V3Payer(); + payer.setOpenid(productOrder.getOpenId()); + req.setPayer(payer); + + return req; + } - private PayAdapterResult getOrderPResult(String response,WxPayOrder record,WxPayAccount payAccount,WxAppinfo appInfo,WxPayService payService) { + private PayAdapterResult getOrderPResult(String response,WxPayService payService,WxAppinfo appInfo,WxPayAccount payAccount,String order_no) { PayAdapterResult par = new PayAdapterResult(); if (StringUtils.isBlank(response)) { par.setSuccess(false); @@ -124,15 +134,13 @@ public class WxMiniAppPayV3AdapterService extends BaseWxPayV3AdapterService impl }else { par.setSuccess(true); par.setMsg("success."); - record.setPrepayId(prepayId); - record.setUpdateTime(new Date()); - par.setData(getPayRetMap(payService,appInfo, prepayId, payAccount, record)); + par.setData(getPayRetMap(payService,appInfo, prepayId, order_no)); } } return par; } - private Map getPayRetMap(WxPayService payService,WxAppinfo appInfo,String prepayId,WxPayAccount payAccount,WxPayOrder record) { + private Map getPayRetMap(WxPayService payService,WxAppinfo appInfo,String prepayId,String order_no) { String timestamp = String.valueOf(Utility.getCurrentTimeStamp()); String noncestr = Utility.generate32UUID(); String signAgent = WxPayV3.getMiniAppPayEntry(payService, appInfo.getAppId(), timestamp, noncestr, prepayId); @@ -143,7 +151,7 @@ public class WxMiniAppPayV3AdapterService extends BaseWxPayV3AdapterService impl returnMap.put("package", "prepay_id=" + prepayId); returnMap.put("paySign", signAgent); returnMap.put("signType", "RSA"); - returnMap.put("payOrderId", String.valueOf(record.getId())); + returnMap.put("payOrderId", order_no); return returnMap; } @@ -210,7 +218,7 @@ public class WxMiniAppPayV3AdapterService extends BaseWxPayV3AdapterService impl V3PayCommonMiniAppReq payReq = generatePayCommonRequest(payAccount,composeOrder,productName,record,openId,appInfo,currentDate); try { String response = WxPayV3.payCommonWithMiniApp(payService, payReq); - return getOrderPResult(response,record,payAccount,appInfo,payService); + return getOrderPResult(response,payService,appInfo,payAccount,record.getId().toString()); }catch(WxPayException e) { log.error("wexin pay v3 error",e); throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),e.getCustomErrorMsg()); @@ -225,6 +233,21 @@ public class WxMiniAppPayV3AdapterService extends BaseWxPayV3AdapterService impl } } + @Override + public PayAdapterResult createPay(ProductOrder order, WxAppinfo appInfo, WxPayAccount payAccount) throws Exception { + + WxPayService payService = maUtil.getWxPayServiceBySelfModel(appInfo, payAccount); + + V3CreatePayReq payReq = generateCreatePayRequest(order,appInfo,payAccount); + try { + String response = WxPayV3.payCommonWithMiniApp(payService, payReq); + return getOrderPResult(response,payService,appInfo,payAccount,order.getOrderNumber()); + }catch(WxPayException e) { + log.error("wexin pay v3 error",e); + throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),e.getCustomErrorMsg()); + } + } + private PayQueryAdapterResult getPayCommonQueryResult(String response) { JSONObject result = JSON.parseObject(response); String transtionId = result.getString("transaction_id"); @@ -241,6 +264,33 @@ public class WxMiniAppPayV3AdapterService extends BaseWxPayV3AdapterService impl PayQueryAdapterResult qresult = new PayQueryAdapterResult(payStatus.getCode(), tradeStateDesc,null, response,transtionId,successTime); return qresult; } + + private PayQueryAdapterResult getPayQueryResult(String response) { + JSONObject result = JSON.parseObject(response); + String transtionId = result.getString("transaction_id"); + String tradeState = result.getString("trade_state"); + String tradeStateDesc = result.getString("trade_state_desc"); + String successTime = result.getString("success_time"); + JSONObject payer = result.getJSONObject("payer"); + String openid = payer.getString("openid"); + EnumProductOrderStatus payStatus = WxPayOrderServiceHelper.getProductOrderStatus(tradeState); + if (null == payStatus) { + throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), "订单查询微信支付状态非法["+tradeState+"]"); + } + if (StringUtils.isBlank(tradeStateDesc)) { + tradeStateDesc = payStatus.getMessage(); + } + PayQueryAdapterResult qresult = new PayQueryAdapterResult(); + qresult.setCode(payStatus.getCode()); + qresult.setMsg(tradeStateDesc); + qresult.setTransactionId(transtionId); + qresult.setOpenId(openid); + if(StringUtils.isNotBlank(successTime)){ + qresult.setPayTime(DateUtils.rfc3339Formatter(successTime)); + } + + return qresult; + } private PayQueryAdapterResult getPayCombineQueryResult(String response) { JSONObject result = JSON.parseObject(response); @@ -298,6 +348,44 @@ public class WxMiniAppPayV3AdapterService extends BaseWxPayV3AdapterService impl } } + /** + * 单商户模式 + * @param order + * @param appInfo + * @param payAccount + * @return + * @throws Exception + */ + @Override + public PayQueryAdapterResult queryPayStatus(ProductOrder order, WxAppinfo appInfo, WxPayAccount payAccount) throws Exception { + WxPayService payService = maUtil.getWxPayServiceBySelfModel(appInfo, payAccount); + V3PayQuery req = new V3PayQuery(); + req.setMchid(payAccount.getMchId()); + req.setOut_trade_no(order.getOrderNumber()); + try { + String response = WxPayV3.payQuery(payService, req); + if (StringUtils.isBlank(response)){ + log.error("pay common v3 query response is null."+JSON.toJSONString(req)); + throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"pay common v3 query response is null."+JSON.toJSONString(req)); + } + return getPayQueryResult(response); + }catch(WxPayException e) { + log.error("pay common v3 query response error",e); + if("ORDER_CLOSED".equals(e.getErrCode())){ + PayQueryAdapterResult result = new PayQueryAdapterResult(); + result.setCode(EnumProductOrderStatus.ORDER_STATUS_OVERTIME_CANCEL.getCode()); + result.setMsg(EnumProductOrderStatus.ORDER_STATUS_OVERTIME_CANCEL.getMessage()); + return result; + }else if("ORDER_NOT_EXIST".equals(e.getErrCode()) || "ORDERNOTEXIST".equals(e.getErrCode())){ + PayQueryAdapterResult result = new PayQueryAdapterResult(); + result.setCode(EnumProductOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode()); + result.setMsg(EnumProductOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getMessage()); + return result; + } + throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),e.getCustomErrorMsg()); + } + } + @Override public int queryPayStatus(PayQueryAdapterResult statusObject, String orderOutNo) throws Exception { return getPayCommonQueryResult((String)statusObject.getData()).getCode(); diff --git a/suimangService/src/main/java/com/iformall/utils/DateUtils.java b/suimangService/src/main/java/com/iformall/utils/DateUtils.java index d19df97..3cc71bc 100644 --- a/suimangService/src/main/java/com/iformall/utils/DateUtils.java +++ b/suimangService/src/main/java/com/iformall/utils/DateUtils.java @@ -360,6 +360,20 @@ public class DateUtils { return formatter.format(date); } + /** + * 获得当前时间前几天 + * + * @param days + * 前几天 + * @return + */ + public static Date getDateBefore(int days, Date myDate) { + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); + long myTime = (myDate.getTime() / 1000) - 60 * 60 * 24 * days; + Date date = new Date(myTime * 1000); + return date; + } + /** * 获得当前时间前几天 * diff --git a/suimangService/src/main/resources/mapper/ProductMapper.xml b/suimangService/src/main/resources/mapper/ProductMapper.xml new file mode 100644 index 0000000..553cc64 --- /dev/null +++ b/suimangService/src/main/resources/mapper/ProductMapper.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + `id`,`tenant_id`,`parent_tenant_id`,`project_type`,`type`, + `cover_img`,`title`,`en_title`,`glod`,`detail`, + `price_dollar`,`sell_price_dollar`,`price_rmb`,`sell_price_rmb`, + `create_date`,`update_date` + + + + where is_del = 0 + and `id` = #{id} + + and `tenant_id` = #{tenantId} + + + and `parent_tenant_id` = #{parentTenantId} + + and `project_type` = #{projectType} + and `type` = #{type} + + and `title` like concat('%', #{title},'%') + + + and `en_title` like concat('%', #{enTitle},'%') + + + + and `create_date` >= #{startDate} + + + and `create_date` <= #{endDate} + + + + and id in + + #{idItem} + + + order by ${sortColumns} + + + + + diff --git a/suimangService/src/main/resources/mapper/ProductOrderMapper.xml b/suimangService/src/main/resources/mapper/ProductOrderMapper.xml new file mode 100644 index 0000000..553ce70 --- /dev/null +++ b/suimangService/src/main/resources/mapper/ProductOrderMapper.xml @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + `id`,`order_number`,`tenant_id`,`parent_tenant_id`,`user_id`,`product_id`,`product_title`,`product_en_title`,`order_status`, + `project_type`,`pay_vendor`,`order_price`,`create_date`,`update_date`, + `remark`,`order_id`,`open_id`,`profit_sharing`,`transaction_id`,`payment`,`payment_time`,`pay_way` + + + + where 1 = 1 + + + and `id` = #{id} + + + + and `order_number` = #{orderNumber} + + + + and `tenant_id` = #{tenantId} + + + and `parent_tenant_id` = #{parentTenantId} + + + + and `user_id` = #{userId} + + + + and `product_id` = #{productId} + + + and `product_title` like concat('%', #{productTitle},'%') + + + and `product_en_title` like concat('%', #{productEnTitle},'%') + + and `project_type` = #{projectType} + and `pay_vendor` = #{payVendor} + + + + and `order_id` = #{orderId} + + + and `profit_sharing` = #{profitSharing} + + + + and `transaction_id` = #{transactionId} + + + + and `order_status` = #{orderStatus} + + + and `create_date` >= #{startDate} + + + and `create_date` <= #{endDate} + + + and `payment_time` >= #{payStartDate} + + + and `payment_time` <= #{payEndDate} + + + + and `order_status` in + + #{sItem} + + + + + and id in + + #{idItem} + + + order by ${sortColumns} + + + + + + + update product_order + set `order_status` = #{orderStatus} + ,`update_date` = #{updateDate} + + ,`open_id` = #{openId} + + + ,`transaction_id` = #{transactionId} + + + ,`payment_time` = #{paymentTime} + + + ,`pay_way` = #{payWay} + + where id = #{id} and `order_status` != #{orderStatus} + + + diff --git a/suimangService/src/main/resources/mapper/UserBasicFromMapper.xml b/suimangService/src/main/resources/mapper/UserBasicFromMapper.xml new file mode 100644 index 0000000..14b4666 --- /dev/null +++ b/suimangService/src/main/resources/mapper/UserBasicFromMapper.xml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + `id`,`tenant_id`,`parent_tenant_id`, + `from_project`,`from_type`,`from_id`,`from_user_id`,`plat`, + `create_date` + + + + where 1 = 1 + and `id` = #{id} + + and `tenant_id` = #{tenantId} + + + and `parent_tenant_id` = #{parentTenantId} + + and `from_project` = #{fromProject} + and `from_type` = #{fromType} + and `from_id` = #{fromId} + and `from_user_id` = #{fromUserId} + and `plat` = #{plat} + + + and `create_date` >= #{startDate} + + + and `create_date` <= #{endDate} + + + + and id in + + #{idItem} + + + order by ${sortColumns} + + + + + diff --git a/suimangService/src/main/resources/mapper/UserBasicPropertyLogMapper.xml b/suimangService/src/main/resources/mapper/UserBasicPropertyLogMapper.xml new file mode 100644 index 0000000..3c957e8 --- /dev/null +++ b/suimangService/src/main/resources/mapper/UserBasicPropertyLogMapper.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + `id`,`tenant_id`,`parent_tenant_id`,`user_id`, + `project_type`,`type`,`befour_gold`,`gold_num`,`after_gold`, + `extra_id`,`remark`,`detail`,`create_date` + + + + where 1 = 1 + and `id` = #{id} + + and `tenant_id` = #{tenantId} + + + and `parent_tenant_id` = #{parentTenantId} + + and `user_id` = #{userId} + and `project_type` = #{projectType} + and `type` = #{type} + + + and `create_date` >= #{startDate} + + + and `create_date` <= #{endDate} + + + + and id in + + #{idItem} + + + order by ${sortColumns} + + + + + diff --git a/suimangService/src/main/resources/mapper/UserBasicPropertyMapper.xml b/suimangService/src/main/resources/mapper/UserBasicPropertyMapper.xml new file mode 100644 index 0000000..e44d4a7 --- /dev/null +++ b/suimangService/src/main/resources/mapper/UserBasicPropertyMapper.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + `id`,`tenant_id`,`parent_tenant_id`, + `digital_avatar_glod`,`digital_avatar_residue_glod`, + `update_date` + + + + where 1 = 1 + and `id` = #{id} + + and `tenant_id` = #{tenantId} + + + and `parent_tenant_id` = #{parentTenantId} + + + + and id in + + #{idItem} + + + order by ${sortColumns} + + + + + + update user_basic_property + set `update_date` = #{updateDate} + ,`digital_avatar_glod` = digital_avatar_glod+#{digitalAvatarGlod} + ,`digital_avatar_residue_glod` = digital_avatar_residue_glod+#{digitalAvatarResidueGlod} + where id = #{id} + + + diff --git a/suimangService/src/main/resources/mapper/WxAppinfoMapper.xml b/suimangService/src/main/resources/mapper/WxAppinfoMapper.xml index b896b43..b422b06 100644 --- a/suimangService/src/main/resources/mapper/WxAppinfoMapper.xml +++ b/suimangService/src/main/resources/mapper/WxAppinfoMapper.xml @@ -15,6 +15,7 @@ + @@ -30,7 +31,7 @@ `id`,`tenant_id`,`app_id`,`parent_app_id`,`name`, `secret`,`token`,`aes_key`,`msg_data_format`,`access_token`,`last_token_time`,`expires_in`, - `pay_id`,`type`,`mould_type`,`enable`,`plat`,`sort_url`,`business_license`,`icp` + `pay_id`,`project_type`,`type`,`mould_type`,`enable`,`plat`,`sort_url`,`business_license`,`icp` @@ -86,6 +87,9 @@ and `pay_id` = #{payId} + + and `project_type` = #{projectType} + and `type` = #{type}