| @@ -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 | |||||
| @@ -0,0 +1,2 @@ | |||||
| ALTER TABLE `wx_appinfo` | |||||
| ADD COLUMN `project_type` smallint(0) AFTER `pay_id`; | |||||
| @@ -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<String, Object> 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<String, String> 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<String, String> 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); | |||||
| } | |||||
| } | |||||
| @@ -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<Product> page = productService.listAsPage(record, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| } | |||||
| @@ -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; | |||||
| } | |||||
| } | |||||
| @@ -1,7 +1,11 @@ | |||||
| package com.iformall.controller; | 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.google.code.kaptcha.Producer; | ||||
| import com.iformall.annotation.AuthIgnore; | import com.iformall.annotation.AuthIgnore; | ||||
| import com.iformall.annotation.TenantIgnore; | |||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.common.Result; | import com.iformall.common.Result; | ||||
| import com.iformall.common.ResultData; | 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.UserConsumptionPackageService; | ||||
| import com.iformall.service.sm.UserCreateVideoNumService; | import com.iformall.service.sm.UserCreateVideoNumService; | ||||
| import com.iformall.utils.Constant; | import com.iformall.utils.Constant; | ||||
| import com.iformall.utils.IPUtil; | |||||
| import com.iformall.utils.PasswordHelper; | import com.iformall.utils.PasswordHelper; | ||||
| import com.iformall.utils.RedisCacheUtils; | import com.iformall.utils.RedisCacheUtils; | ||||
| import io.swagger.annotations.Api; | 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.beans.factory.annotation.Qualifier; | ||||
| import org.springframework.data.redis.core.RedisTemplate; | import org.springframework.data.redis.core.RedisTemplate; | ||||
| import org.springframework.web.bind.annotation.*; | 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.imageio.ImageIO; | ||||
| import javax.servlet.ServletOutputStream; | import javax.servlet.ServletOutputStream; | ||||
| import javax.servlet.http.HttpServletRequest; | |||||
| import javax.servlet.http.HttpServletResponse; | import javax.servlet.http.HttpServletResponse; | ||||
| import java.awt.image.BufferedImage; | import java.awt.image.BufferedImage; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| @@ -99,6 +107,7 @@ public class WxUserGrantController extends BaseController { | |||||
| @Autowired | @Autowired | ||||
| private UserConsumptionPackageService userConsumptionPackageService; | private UserConsumptionPackageService userConsumptionPackageService; | ||||
| @Autowired | @Autowired | ||||
| private WxCUserAuthorityService wxCUserAuthorityService; | private WxCUserAuthorityService wxCUserAuthorityService; | ||||
| @@ -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<ProductOrder> orderList = productOrderService.findList(productOrderQ); | |||||
| for (ProductOrder order: orderList) { | |||||
| try{ | |||||
| productOrderService.handldSharing(order); | |||||
| }catch(Exception e){ | |||||
| logger.error("分账失败:" + e.getMessage()); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -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; | |||||
| } | |||||
| @@ -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<Integer> 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; | |||||
| } | |||||
| @@ -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; | |||||
| } | |||||
| @@ -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; | |||||
| } | |||||
| @@ -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; | |||||
| } | |||||
| @@ -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; | |||||
| } | |||||
| @@ -36,6 +36,8 @@ public class WxAppinfo extends BaseTenantEntity { | |||||
| private Integer expiresIn; | private Integer expiresIn; | ||||
| @io.swagger.annotations.ApiModelProperty(value="支付ID,参看wx_pay_account",name="payId") | @io.swagger.annotations.ApiModelProperty(value="支付ID,参看wx_pay_account",name="payId") | ||||
| private Long payId; | private Long payId; | ||||
| @io.swagger.annotations.ApiModelProperty(value="EnumProject",name="projectType") | |||||
| private Integer projectType; | |||||
| @io.swagger.annotations.ApiModelProperty(value="1B端2C端",name="type") | @io.swagger.annotations.ApiModelProperty(value="1B端2C端",name="type") | ||||
| private Integer type; | private Integer type; | ||||
| @io.swagger.annotations.ApiModelProperty(value="模板类型",name="mouldType") | @io.swagger.annotations.ApiModelProperty(value="模板类型",name="mouldType") | ||||
| @@ -11,6 +11,7 @@ import com.iformall.douyin.pay.orderQuery.QueryRefundResult; | |||||
| import com.iformall.douyin.pay.orderQuery.QuerySettleResult; | import com.iformall.douyin.pay.orderQuery.QuerySettleResult; | ||||
| import com.iformall.douyin.pay.preOrder.*; | import com.iformall.douyin.pay.preOrder.*; | ||||
| import com.iformall.enums.EnumPayStatus; | import com.iformall.enums.EnumPayStatus; | ||||
| import com.iformall.enums.EnumProductOrderStatus; | |||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.utils.sign.SignUtils; | import com.iformall.utils.sign.SignUtils; | ||||
| @@ -190,19 +191,19 @@ public class DouYinPayHelper { | |||||
| public static int getPayStatusFromOrderQueryResult(OrderQueryResult result,String payOrderNo) { | public static int getPayStatusFromOrderQueryResult(OrderQueryResult result,String payOrderNo) { | ||||
| if(result == null){ | if(result == null){ | ||||
| return EnumPayStatus.PAY_STATUS_ORDER_NOT_EXISTS.getCode(); | |||||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), "订单查询抖音支付状态失败"+payOrderNo); | |||||
| } | } | ||||
| String orderStatus = result.getOrderStatus(); | String orderStatus = result.getOrderStatus(); | ||||
| if(StringUtils.isBlank(orderStatus)){ | if(StringUtils.isBlank(orderStatus)){ | ||||
| return EnumPayStatus.PAY_STATUS_FAIL.getCode(); | |||||
| return EnumProductOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode(); | |||||
| }else if("PROCESSING".equals(orderStatus)){//以观后效 | }else if("PROCESSING".equals(orderStatus)){//以观后效 | ||||
| return EnumPayStatus.PAY_STATUS_NOTPAY.getCode(); | |||||
| return EnumProductOrderStatus.ORDER_STATUS_PENDING_PAYMENTING.getCode(); | |||||
| }else if("SUCCESS".equals(orderStatus)){ | }else if("SUCCESS".equals(orderStatus)){ | ||||
| return EnumPayStatus.PAY_STATUS_SUCCESS.getCode(); | |||||
| return EnumProductOrderStatus.ORDER_STATUS_PAYMENT_SUCCESS.getCode(); | |||||
| }else if("FAIL".equals(orderStatus)){ | }else if("FAIL".equals(orderStatus)){ | ||||
| return EnumPayStatus.PAY_STATUS_FAIL.getCode(); | |||||
| return EnumProductOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode(); | |||||
| }else if("TIMEOUT".equals(orderStatus)){ | }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); | throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), "订单查询抖音支付状态失败"+payOrderNo); | ||||
| } | } | ||||
| @@ -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; | |||||
| } | |||||
| } | |||||
| @@ -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; | |||||
| } | |||||
| } | |||||
| @@ -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; | |||||
| } | |||||
| } | |||||
| @@ -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<Integer> getAllCodes(){ | |||||
| List<Integer> 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; | |||||
| } | |||||
| } | |||||
| @@ -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; | |||||
| } | |||||
| } | |||||
| @@ -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; | |||||
| } | |||||
| } | |||||
| @@ -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; | |||||
| } | |||||
| } | |||||
| @@ -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; | |||||
| } | |||||
| } | |||||
| @@ -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<Product, Long>{ | |||||
| List<Product> findList(Product record); | |||||
| } | |||||
| @@ -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<ProductOrder, Long> { | |||||
| List<ProductOrder> findList(ProductOrder record); | |||||
| int orderPayUpdStatus(ProductOrder productOrder); | |||||
| } | |||||
| @@ -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<UserBasicFrom, Long>{ | |||||
| List<UserBasicFrom> findList(UserBasicFrom record); | |||||
| } | |||||
| @@ -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<UserBasicPropertyLog, Long>{ | |||||
| List<UserBasicPropertyLog> findList(UserBasicPropertyLog record); | |||||
| } | |||||
| @@ -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<UserBasicProperty, Long>{ | |||||
| List<UserBasicProperty> findList(UserBasicProperty record); | |||||
| int addGlod(UserBasicProperty userBasicProperty); | |||||
| } | |||||
| @@ -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.SFTCombinePayCommonMiniAppReq; | ||||
| import com.iformall.service.pay.service.pay.wx.sft.entity.SFTPayCommonMiniAppReq; | 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.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.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.V3PayShareQueryReq; | ||||
| import com.iformall.service.pay.service.share.wx.v3.entity.V3PayShareReq; | 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_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 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_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_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"; | 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端小程序关联 | * 注意:1. 需要登录到特约商户号自己的商户后台,产品中心---APPID账号管理----我关联的appId账号,把C端小程序关联 | ||||
| * 2. 需要设置白名单IP | * 2. 需要设置白名单IP | ||||
| * 3.微信不能开通运营账户,如果运营账户开通,则资金会从运营账户里面扣取,不会从基本账户扣取 | * 3.微信不能开通运营账户,如果运营账户开通,则资金会从运营账户里面扣取,不会从基本账户扣取 | ||||
| * @param params | |||||
| * 请求参数 | |||||
| * @param certPath | |||||
| * 证书文件目录 | |||||
| * @param certPassword | |||||
| * 证书密码 | * 证书密码 | ||||
| * @return {String} | * @return {String} | ||||
| * @throws WxPayException | * @throws WxPayException | ||||
| @@ -129,12 +128,6 @@ public class WxPayV3 { | |||||
| /** | /** | ||||
| * 查询商家转账到零钱 | * 查询商家转账到零钱 | ||||
| * https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter4_3_5.shtml | * https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter4_3_5.shtml | ||||
| * @param params | |||||
| * 请求参数 | |||||
| * @param certPath | |||||
| * 证书文件目录 | |||||
| * @param certPassword | |||||
| * 证书密码 | |||||
| * @return {String} | * @return {String} | ||||
| * @throws WxPayException | * @throws WxPayException | ||||
| */ | */ | ||||
| @@ -143,6 +136,14 @@ public class WxPayV3 { | |||||
| param.put("need_query_detail", false); | param.put("need_query_detail", false); | ||||
| return payService.postV3WithWechatpaySerial(String.format(MERCHANT_TRANSFER_QUERY_URL, batchNo), JSON.toJSONString(param)); | 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 | * 普通支付-小程序下单 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 { | public static String payCommonWithMiniApp(WxPayService payService,V3PayCommonMiniAppReq payReq) throws WxPayException { | ||||
| return payService.postV3WithWechatpaySerial(PAY_COMMON_MINIAPP_URL, JSON.toJSONString(payReq)); | 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 | * 普通支付-查询https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter4_5_2.shtml | ||||
| @@ -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<ProductOrder> 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<ProductOrder> findList(ProductOrder record); | |||||
| void handldSharing(ProductOrder order); | |||||
| } | |||||
| @@ -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<Product> listAsPage(Product record, Integer pageIndex, Integer pageSize); | |||||
| Product getById(Long id); | |||||
| } | |||||
| @@ -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<UserBasicFrom> listAsPage(UserBasicFrom record, Integer pageIndex, Integer pageSize); | |||||
| void saveForm(UserBasicFrom from); | |||||
| } | |||||
| @@ -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<UserBasicPropertyLog> listAsPage(UserBasicPropertyLog record, Integer pageIndex, Integer pageSize); | |||||
| } | |||||
| @@ -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<UserBasicProperty> listAsPage(UserBasicProperty record, Integer pageIndex, Integer pageSize); | |||||
| void addRechargeGlod(Long userId, Integer projectType, Long extraId, Integer glod); | |||||
| } | |||||
| @@ -7,6 +7,7 @@ import com.iformall.domain.po.WxProjectConfig; | |||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.enums.EnumAppPlat; | import com.iformall.enums.EnumAppPlat; | ||||
| import com.iformall.enums.EnumPayWay; | import com.iformall.enums.EnumPayWay; | ||||
| import com.iformall.enums.EnumProject; | |||||
| import javax.servlet.http.HttpServletRequest; | import javax.servlet.http.HttpServletRequest; | ||||
| import javax.servlet.http.HttpServletResponse; | import javax.servlet.http.HttpServletResponse; | ||||
| @@ -90,4 +91,8 @@ public interface WxAppinfoService { | |||||
| WxAppinfo getCAppInfoFromRedis(String tenantId, EnumAppPlat appPlat); | WxAppinfo getCAppInfoFromRedis(String tenantId, EnumAppPlat appPlat); | ||||
| WxAppinfo getProjectCAppInfo(Integer projectType, Integer plat); | |||||
| WxAppinfo getProjectCAppInfoFromRedis(Integer projectType, Integer plat); | |||||
| } | } | ||||
| @@ -1,6 +1,8 @@ | |||||
| package com.iformall.service.cuser; | package com.iformall.service.cuser; | ||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.domain.po.CUser; | import com.iformall.domain.po.CUser; | ||||
| import com.iformall.domain.po.UserBasicFrom; | |||||
| import com.iformall.domain.po.WxCUserBasicInfo; | import com.iformall.domain.po.WxCUserBasicInfo; | ||||
| import com.iformall.domain.po.WxCUserFrom; | import com.iformall.domain.po.WxCUserFrom; | ||||
| import com.iformall.domain.po.base.BaseCUserEntity; | import com.iformall.domain.po.base.BaseCUserEntity; | ||||
| @@ -34,6 +36,9 @@ public class BasicCUserService { | |||||
| @Autowired | @Autowired | ||||
| private WxCUserBasicInfoService wxCUserBasicInfoService; | private WxCUserBasicInfoService wxCUserBasicInfoService; | ||||
| @Autowired | |||||
| private UserBasicFromService userBasicFromService; | |||||
| @Autowired | @Autowired | ||||
| private MallCooUserInfoService mallCooUserInfoService; | private MallCooUserInfoService mallCooUserInfoService; | ||||
| @@ -100,75 +105,31 @@ public class BasicCUserService { | |||||
| cleanCuserToken(user.getToken()); | 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 (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); | wxCUserBasicInfoService.update(basicInfo); | ||||
| cleanBasicUser(basicInfo.getId()); | |||||
| return basicInfo.getId(); | |||||
| return basicInfo; | |||||
| } else { | } 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) { | public void setCache(String token,BaseCUserEntity baseUser) { | ||||
| @@ -2,9 +2,7 @@ package com.iformall.service.cuser; | |||||
| import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; | import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; | ||||
| import com.iformall.domain.dto.WxCUserBasicInfoDto; | 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.BaseCUserEntity; | ||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.domain.vo.UserCountVo; | 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); | 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); | void savePhoneToBasicInfo(CUser user, String phone); | ||||
| CUser handleLoginUser(CUser cUser, WxCUserFrom wxCUserFrom); | |||||
| CUser handleLoginUser(CUser cUser); | |||||
| CUser getById(Long id, String tenantId); | CUser getById(Long id, String tenantId); | ||||
| CUser getByOpenId(String openId, String tenantId); | CUser getByOpenId(String openId, String tenantId); | ||||
| @@ -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<UserCountVo> findCountHistory(WxCUserBasicInfoDto dto) { | |||||
| return null; | |||||
| } | |||||
| @Override | |||||
| public void actionAfterLogin(CUser user) { | |||||
| } | |||||
| @Override | |||||
| public String updateQrCode(CUser user) { | |||||
| return null; | |||||
| } | |||||
| @Override | |||||
| public List<UserStructureVo> findCountData(WxCUserBasicInfoDto dto) { | |||||
| return null; | |||||
| } | |||||
| private void updateTokenCache(String token,Object cuser) { | |||||
| BaseCUserEntity baseUser = this.getByObj(cuser); | |||||
| setCache(token,baseUser); | |||||
| } | |||||
| } | |||||
| @@ -150,10 +150,10 @@ public class TtCUserServiceAdapter extends BasicCUserService implements CUserSer | |||||
| } | } | ||||
| @Override | @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); | TtMaService ttMaService = maUtil.getTtMaService(wxAppinfo); | ||||
| WxMaPhoneNumberInfo phoneNoInfo = ttMaService.getUserService().getPhoneNoInfo(cuser.getSessionKey(), encryptedData, iv); | WxMaPhoneNumberInfo phoneNoInfo = ttMaService.getUserService().getPhoneNoInfo(cuser.getSessionKey(), encryptedData, iv); | ||||
| if (null != phoneNoInfo) { | |||||
| if (null != phoneNoInfo && StringUtils.isNotBlank(phoneNoInfo.getPhoneNumber())) { | |||||
| if(phoneNoInfo.getPhoneNumber().contains("*")){ | if(phoneNoInfo.getPhoneNumber().contains("*")){ | ||||
| throw new MallinkException(ErrorCode.PHONE_IS_ENCRYPTED); | throw new MallinkException(ErrorCode.PHONE_IS_ENCRYPTED); | ||||
| } | } | ||||
| @@ -163,23 +163,16 @@ public class TtCUserServiceAdapter extends BasicCUserService implements CUserSer | |||||
| updateUser.setPhone(phoneNoInfo.getPhoneNumber()); | updateUser.setPhone(phoneNoInfo.getPhoneNumber()); | ||||
| updateUser.setPurePhone(phoneNoInfo.getPurePhoneNumber()); | updateUser.setPurePhone(phoneNoInfo.getPurePhoneNumber()); | ||||
| updateUser.setCountryCode(phoneNoInfo.getCountryCode()); | updateUser.setCountryCode(phoneNoInfo.getCountryCode()); | ||||
| // 更新到basicinfo | // 更新到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()); | updateUser.setUpdateDate(new Date()); | ||||
| ttCUserMapper.updateById(updateUser); | 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 { | } else { | ||||
| throw new MallinkException(ErrorCode.PHONE_DECODE_ERR); | throw new MallinkException(ErrorCode.PHONE_DECODE_ERR); | ||||
| } | } | ||||
| @@ -193,24 +186,17 @@ public class TtCUserServiceAdapter extends BasicCUserService implements CUserSer | |||||
| updateUser.setPhone(phone); | updateUser.setPhone(phone); | ||||
| // 更新到basicinfo | // 更新到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()); | updateUser.setUpdateDate(new Date()); | ||||
| ttCUserMapper.updateById(updateUser); | 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 | @Override | ||||
| public CUser handleLoginUser(CUser cUser, WxCUserFrom wxCUserFrom) { | |||||
| public CUser handleLoginUser(CUser cUser) { | |||||
| TtCUser newUser = new TtCUser(); | TtCUser newUser = new TtCUser(); | ||||
| newUser.updateTenantInfo(cUser); | newUser.updateTenantInfo(cUser); | ||||
| newUser.setAppId(cUser.getAppId()); | newUser.setAppId(cUser.getAppId()); | ||||
| @@ -229,8 +215,6 @@ public class TtCUserServiceAdapter extends BasicCUserService implements CUserSer | |||||
| user.setActiveTime(new Date()); | user.setActiveTime(new Date()); | ||||
| user.setUpdateDate(new Date()); | user.setUpdateDate(new Date()); | ||||
| ttCUserMapper.updateById(user); | ttCUserMapper.updateById(user); | ||||
| wxCUserFrom.setIsNewUser(EnumYesOrNo.NO.getCode()); | |||||
| } else { | } else { | ||||
| user = new TtCUser(); | user = new TtCUser(); | ||||
| user.setNickName(AppUtils.getAppId());//新用户随机昵称,短8位 | user.setNickName(AppUtils.getAppId());//新用户随机昵称,短8位 | ||||
| @@ -244,19 +228,13 @@ public class TtCUserServiceAdapter extends BasicCUserService implements CUserSer | |||||
| user.setRegisterIp(cUser.getRegisterIp()); | user.setRegisterIp(cUser.getRegisterIp()); | ||||
| user.setSessionKey(cUser.getSessionKey()); | user.setSessionKey(cUser.getSessionKey()); | ||||
| user.setUnionId(cUser.getUnionId()); | user.setUnionId(cUser.getUnionId()); | ||||
| user.setSceneAddress(wxCUserFrom.getSceneAddress()); | |||||
| user.setScene(wxCUserFrom.getScene()); | |||||
| user.setExtraInfo(cUser.getExtraInfo()); | user.setExtraInfo(cUser.getExtraInfo()); | ||||
| user.setLoginCount(1); | user.setLoginCount(1); | ||||
| user.setActiveTime(new Date()); | user.setActiveTime(new Date()); | ||||
| user.setCreateDate(new Date()); | user.setCreateDate(new Date()); | ||||
| user.setUpdateDate(new Date()); | user.setUpdateDate(new Date()); | ||||
| ttCUserMapper.insert(user); | ttCUserMapper.insert(user); | ||||
| wxCUserFrom.setIsNewUser(EnumYesOrNo.YES.getCode()); | |||||
| } | } | ||||
| wxCUserFrom.setCUserId(user.getId()); | |||||
| actionMsgAfterLogin(wxCUserFrom); | |||||
| updateTokenCache(user.getToken(), user); | updateTokenCache(user.getToken(), user); | ||||
| return user; | return user; | ||||
| } | } | ||||
| @@ -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<UserCountVo> findCountHistory(WxCUserBasicInfoDto dto) { | |||||
| return null; | |||||
| } | |||||
| @Override | |||||
| public void actionAfterLogin(CUser user) { | |||||
| } | |||||
| @Override | |||||
| public String updateQrCode(CUser user) { | |||||
| return null; | |||||
| } | |||||
| @Override | |||||
| public List<UserStructureVo> 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); | |||||
| } | |||||
| } | |||||
| @@ -162,10 +162,10 @@ public class WxCUserServiceAdapter extends BasicCUserService implements CUserSer | |||||
| } | } | ||||
| @Override | @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); | WxMaService wxMaService = this.getWxMaService(wxAppinfo, isFmOpen); | ||||
| WxMaPhoneNumberInfo phoneNoInfo = wxMaService.getUserService().getPhoneNoInfo(cuser.getSessionKey(), encryptedData, iv); | WxMaPhoneNumberInfo phoneNoInfo = wxMaService.getUserService().getPhoneNoInfo(cuser.getSessionKey(), encryptedData, iv); | ||||
| if (null != phoneNoInfo) { | |||||
| if (null != phoneNoInfo && StringUtils.isNotBlank(phoneNoInfo.getPhoneNumber())) { | |||||
| logger.info("解密用户手机号 {}" + phoneNoInfo.toString()); | logger.info("解密用户手机号 {}" + phoneNoInfo.toString()); | ||||
| if(phoneNoInfo.getPhoneNumber().contains("*")){ | if(phoneNoInfo.getPhoneNumber().contains("*")){ | ||||
| throw new MallinkException(ErrorCode.PHONE_IS_ENCRYPTED); | throw new MallinkException(ErrorCode.PHONE_IS_ENCRYPTED); | ||||
| @@ -178,21 +178,14 @@ public class WxCUserServiceAdapter extends BasicCUserService implements CUserSer | |||||
| updateUser.setCountryCode(phoneNoInfo.getCountryCode()); | updateUser.setCountryCode(phoneNoInfo.getCountryCode()); | ||||
| // 更新到basicinfo | // 更新到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()); | updateUser.setUpdateDate(new Date()); | ||||
| wxCUserMapper.updateById(updateUser); | 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 { | } else { | ||||
| throw new MallinkException(ErrorCode.PHONE_DECODE_ERR); | throw new MallinkException(ErrorCode.PHONE_DECODE_ERR); | ||||
| } | } | ||||
| @@ -205,25 +198,17 @@ public class WxCUserServiceAdapter extends BasicCUserService implements CUserSer | |||||
| updateUser.updateTenantInfo(user); | updateUser.updateTenantInfo(user); | ||||
| updateUser.setPhone(phone); | 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()); | updateUser.setUpdateDate(new Date()); | ||||
| wxCUserMapper.updateById(updateUser); | 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 | @Override | ||||
| public CUser handleLoginUser(CUser cUser, WxCUserFrom wxCUserFrom) { | |||||
| public CUser handleLoginUser(CUser cUser) { | |||||
| WxCUser newUser = new WxCUser(); | WxCUser newUser = new WxCUser(); | ||||
| newUser.updateTenantInfo(cUser); | newUser.updateTenantInfo(cUser); | ||||
| newUser.setAppId(cUser.getAppId()); | newUser.setAppId(cUser.getAppId()); | ||||
| @@ -231,46 +216,37 @@ public class WxCUserServiceAdapter extends BasicCUserService implements CUserSer | |||||
| WxCUser user = wxCUserMapper.findByOpenId(newUser); | WxCUser user = wxCUserMapper.findByOpenId(newUser); | ||||
| Date now = new Date(); | |||||
| if (user != null) { | if (user != null) { | ||||
| // 已有用户 | // 已有用户 | ||||
| user.createToken(new Date(),user.getTenantId()); | user.createToken(new Date(),user.getTenantId()); | ||||
| user.setRegisterIp(cUser.getRegisterIp()); | |||||
| user.setSessionKey(cUser.getSessionKey()); | user.setSessionKey(cUser.getSessionKey()); | ||||
| user.setUnionId(cUser.getUnionId()); | user.setUnionId(cUser.getUnionId()); | ||||
| user.setExtraInfo(cUser.getExtraInfo()); | user.setExtraInfo(cUser.getExtraInfo()); | ||||
| user.setLoginCount(user.getLoginCount() + 1); | user.setLoginCount(user.getLoginCount() + 1); | ||||
| user.setActiveTime(new Date()); | |||||
| user.setUpdateDate(new Date()); | |||||
| user.setActiveTime(now); | |||||
| user.setUpdateDate(now); | |||||
| wxCUserMapper.updateById(user); | wxCUserMapper.updateById(user); | ||||
| wxCUserFrom.setIsNewUser(EnumYesOrNo.NO.getCode()); | |||||
| } else { | } else { | ||||
| // 新用户 | // 新用户 | ||||
| user = new WxCUser(); | user = new WxCUser(); | ||||
| user.setNickName(AppUtils.getAppId());//新用户随机昵称,短8位 | |||||
| user.setNickName("未设置昵称"); | |||||
| user.updateTenantInfo(cUser); | user.updateTenantInfo(cUser); | ||||
| user.setAppId(cUser.getAppId()); | user.setAppId(cUser.getAppId()); | ||||
| user.setOpenId(cUser.getOpenId()); | user.setOpenId(cUser.getOpenId()); | ||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| user.setId(idWorker.nextId()); | user.setId(idWorker.nextId()); | ||||
| user.createToken(new Date(),user.getTenantId()); | |||||
| user.setRegisterIp(cUser.getRegisterIp()); | user.setRegisterIp(cUser.getRegisterIp()); | ||||
| user.setSessionKey(cUser.getSessionKey()); | user.setSessionKey(cUser.getSessionKey()); | ||||
| user.setUnionId(cUser.getUnionId()); | user.setUnionId(cUser.getUnionId()); | ||||
| user.setSceneAddress(wxCUserFrom.getSceneAddress()); | |||||
| user.setScene(wxCUserFrom.getScene()); | |||||
| user.setExtraInfo(cUser.getExtraInfo()); | user.setExtraInfo(cUser.getExtraInfo()); | ||||
| user.setLoginCount(1); | 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); | wxCUserMapper.insert(user); | ||||
| wxCUserFrom.setIsNewUser(EnumYesOrNo.YES.getCode()); | |||||
| } | } | ||||
| wxCUserFrom.setCUserId(user.getId()); | |||||
| actionMsgAfterLogin(wxCUserFrom); | |||||
| updateTokenCache(user.getToken(), user); | |||||
| return user; | return user; | ||||
| } | } | ||||
| @@ -72,6 +72,25 @@ public class WxPayOrderServiceHelper { | |||||
| } | } | ||||
| return null; | 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<String, String> returnMap,String payOrderNo) { | public static int getPayStatusFromMap(Map<String, String> returnMap,String payOrderNo) { | ||||
| String return_code = returnMap.get("return_code"); | String return_code = returnMap.get("return_code"); | ||||
| @@ -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<ProductOrder> 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<ProductOrder> 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() | |||||
| } | |||||
| } | |||||
| @@ -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<Product> 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); | |||||
| } | |||||
| } | |||||
| @@ -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<UserBasicFrom> 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){} | |||||
| } | |||||
| } | |||||
| @@ -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<UserBasicPropertyLog> listAsPage(UserBasicPropertyLog record, Integer pageIndex, Integer pageSize) { | |||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> userBasicPropertyLogMapper.findList(record)); | |||||
| } | |||||
| } | |||||
| @@ -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<UserBasicProperty> 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); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -8,10 +8,7 @@ import com.iformall.domain.po.WxAppinfo; | |||||
| import com.iformall.domain.po.WxCoupon; | import com.iformall.domain.po.WxCoupon; | ||||
| import com.iformall.domain.po.WxProjectConfig; | import com.iformall.domain.po.WxProjectConfig; | ||||
| import com.iformall.domain.po.base.TenantEntity; | 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.mapper.WxAppinfoMapper; | ||||
| import com.iformall.service.WxAppinfoService; | import com.iformall.service.WxAppinfoService; | ||||
| import com.iformall.service.WxMallService; | import com.iformall.service.WxMallService; | ||||
| @@ -239,6 +236,37 @@ public class WxAppinfoServiceImpl implements WxAppinfoService { | |||||
| return record; | 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){ | private void deleteRedis(Long id){ | ||||
| WxAppinfo record = this.getById(id); | WxAppinfo record = this.getById(id); | ||||
| if(record != null){ | if(record != null){ | ||||
| @@ -991,6 +991,7 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService,IExc | |||||
| @Override | @Override | ||||
| public void update(WxCUserBasicInfo record) { | public void update(WxCUserBasicInfo record) { | ||||
| record.setUpdateDate(new Date()); | |||||
| wxCUserBasicInfoMapper.updateById(record); | wxCUserBasicInfoMapper.updateById(record); | ||||
| } | } | ||||
| @@ -4,6 +4,7 @@ import java.util.Map; | |||||
| import java.util.concurrent.ConcurrentHashMap; | import java.util.concurrent.ConcurrentHashMap; | ||||
| import com.iformall.enums.EnumAppPlat; | import com.iformall.enums.EnumAppPlat; | ||||
| import com.iformall.enums.EnumPayVersion; | 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.douyin.TtRefundAdapterService; | ||||
| import com.iformall.service.pay.service.refund.wx.v2.WxRefundAdapterService; | import com.iformall.service.pay.service.refund.wx.v2.WxRefundAdapterService; | ||||
| import com.iformall.service.pay.service.refund.wx.v3.WxRefundV3AdapterService; | import com.iformall.service.pay.service.refund.wx.v3.WxRefundV3AdapterService; | ||||
| @@ -45,6 +46,9 @@ public class PayServiceFactory { | |||||
| private Map<String,PayShareAdapterService> shareMap = null; | private Map<String,PayShareAdapterService> shareMap = null; | ||||
| private Map<String,RefundPayAdapterService> refundMap = null; | private Map<String,RefundPayAdapterService> refundMap = null; | ||||
| private Map<String,CashOutAdapterService> cashoutMap = null; | private Map<String,CashOutAdapterService> cashoutMap = null; | ||||
| private Map<String,PayAdapterService> payVendorServiceMap = null; | |||||
| private Map<String,PayShareAdapterService> payVendorShareMap = null; | |||||
| @Autowired | @Autowired | ||||
| WxMiniAppPayAdapterService wxMiniAppPayService; | WxMiniAppPayAdapterService wxMiniAppPayService; | ||||
| @@ -118,6 +122,18 @@ public class PayServiceFactory { | |||||
| } | } | ||||
| return qrcodeMap; | return qrcodeMap; | ||||
| } | } | ||||
| private Map<String,PayAdapterService> getPayVendorServiceMap() { | |||||
| if (null == payVendorServiceMap) { | |||||
| payVendorServiceMap = new ConcurrentHashMap<String,PayAdapterService>(); | |||||
| 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<String,PayShareAdapterService> getShareMap(){ | private Map<String,PayShareAdapterService> getShareMap(){ | ||||
| if (null == shareMap ) { | if (null == shareMap ) { | ||||
| @@ -170,6 +186,18 @@ public class PayServiceFactory { | |||||
| } | } | ||||
| return shareMap; | return shareMap; | ||||
| } | } | ||||
| private Map<String,PayShareAdapterService> getPayVendorShareMap(){ | |||||
| if (null == payVendorShareMap ) { | |||||
| payVendorShareMap = new ConcurrentHashMap<String, PayShareAdapterService>(); | |||||
| 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<String,RefundPayAdapterService> getRefundMap(){ | private Map<String,RefundPayAdapterService> getRefundMap(){ | ||||
| if (null == refundMap ) { | if (null == refundMap ) { | ||||
| @@ -202,6 +230,14 @@ public class PayServiceFactory { | |||||
| return service; | 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{ | public PayAdapterService getQrcodeService(Integer type,Integer payVersion) throws MallinkException{ | ||||
| PayAdapterService service = getQrcodeMap().get(type+"_"+payVersion); | PayAdapterService service = getQrcodeMap().get(type+"_"+payVersion); | ||||
| if (null == service) { | if (null == service) { | ||||
| @@ -241,6 +277,14 @@ public class PayServiceFactory { | |||||
| } | } | ||||
| return shareService; | 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{ | public RefundPayAdapterService getRefundPayAdapterService(Integer type,Integer payVersion) throws MallinkException{ | ||||
| RefundPayAdapterService refundService = getRefundMap().get(type+"_"+payVersion); | RefundPayAdapterService refundService = getRefundMap().get(type+"_"+payVersion); | ||||
| @@ -29,6 +29,15 @@ public interface PayAdapterService { | |||||
| */ | */ | ||||
| public PayAdapterResult pay(WxPayAccount payAccount,WxPayOrder record ,WxComposeOrder composeOrder,List<WxOrder> childOrders,String productName,EnumPayShare isShare,WxAppinfo appInfo,Date currentDate, PayExtraParam params) throws Exception; | public PayAdapterResult pay(WxPayAccount payAccount,WxPayOrder record ,WxComposeOrder composeOrder,List<WxOrder> 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查询支付结果 | * 查询支付结果,调用对应端的API查询支付结果 | ||||
| * @param oldRecord WxPayOrder | * @param oldRecord WxPayOrder | ||||
| @@ -39,6 +48,8 @@ public interface PayAdapterService { | |||||
| * @throws Exception | * @throws Exception | ||||
| */ | */ | ||||
| public PayQueryAdapterResult queryPayStatus(WxPayOrder oldRecord,WxAppinfo appInfo,WxPayAccount payAccount) throws Exception; | public PayQueryAdapterResult queryPayStatus(WxPayOrder oldRecord,WxAppinfo appInfo,WxPayAccount payAccount) throws Exception; | ||||
| public PayQueryAdapterResult queryPayStatus(ProductOrder order,WxAppinfo appInfo,WxPayAccount payAccount) throws Exception; | |||||
| /** | /** | ||||
| * 根据返回结果对象解析出支付状态 | * 根据返回结果对象解析出支付状态 | ||||
| @@ -11,6 +11,7 @@ import com.iformall.domain.vo.WxOrderCouponVo; | |||||
| import com.iformall.douyin.miniapp.api.TtMaService; | import com.iformall.douyin.miniapp.api.TtMaService; | ||||
| import com.iformall.douyin.pay.DouYinPayHelper; | import com.iformall.douyin.pay.DouYinPayHelper; | ||||
| import com.iformall.douyin.pay.TtPayService; | 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.CreatePreOrderResult; | ||||
| import com.iformall.douyin.pay.preOrder.DouYinCreatePreOrder; | import com.iformall.douyin.pay.preOrder.DouYinCreatePreOrder; | ||||
| import com.iformall.douyin.payv2.request.TtPayUnifiedOrderV2Request; | import com.iformall.douyin.payv2.request.TtPayUnifiedOrderV2Request; | ||||
| @@ -19,6 +20,7 @@ import com.iformall.enums.*; | |||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.mapper.*; | import com.iformall.mapper.*; | ||||
| import com.iformall.service.WxCouponService; | import com.iformall.service.WxCouponService; | ||||
| import com.iformall.service.helper.WxPayOrderServiceHelper; | |||||
| import com.iformall.service.order.OrderAdapterService; | import com.iformall.service.order.OrderAdapterService; | ||||
| import com.iformall.service.order.OrderFactory; | import com.iformall.service.order.OrderFactory; | ||||
| import com.iformall.service.order.entity.WxComposeChildOrderShare; | import com.iformall.service.order.entity.WxComposeChildOrderShare; | ||||
| @@ -221,12 +223,52 @@ public class TtMiniAppPayAdapterService extends BaseTtPayAdapterService implemen | |||||
| // return par; | // 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 | @Override | ||||
| public PayQueryAdapterResult queryPayStatus(WxPayOrder oldRecord, WxAppinfo appInfo, | public PayQueryAdapterResult queryPayStatus(WxPayOrder oldRecord, WxAppinfo appInfo, | ||||
| WxPayAccount payAccount) throws Exception { | WxPayAccount payAccount) throws Exception { | ||||
| return super.queryPayStatus(oldRecord,appInfo, payAccount); | 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 | @Override | ||||
| public int queryPayStatus(PayQueryAdapterResult statusObject, String orderOutNo) throws Exception { | public int queryPayStatus(PayQueryAdapterResult statusObject, String orderOutNo) throws Exception { | ||||
| return super.queryPayStatus(statusObject, orderOutNo); | return super.queryPayStatus(statusObject, orderOutNo); | ||||
| @@ -1,6 +1,7 @@ | |||||
| package com.iformall.service.pay.service.pay.entity; | package com.iformall.service.pay.service.pay.entity; | ||||
| import java.io.Serializable; | import java.io.Serializable; | ||||
| import java.util.Date; | |||||
| import lombok.Data; | import lombok.Data; | ||||
| import lombok.ToString; | import lombok.ToString; | ||||
| @@ -10,8 +11,10 @@ import lombok.ToString; | |||||
| public class PayQueryAdapterResult implements Serializable{ | public class PayQueryAdapterResult implements Serializable{ | ||||
| private static final long serialVersionUID = -8271349001408799798L; | 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.code = code; | ||||
| this.msg = msg; | this.msg = msg; | ||||
| this.way = way; | this.way = way; | ||||
| @@ -20,16 +23,22 @@ public class PayQueryAdapterResult implements Serializable{ | |||||
| this.endTimeStr = endTimeStr; | this.endTimeStr = endTimeStr; | ||||
| } | } | ||||
| private int code; | |||||
| private Integer code; | |||||
| private Integer way; | |||||
| private String msg; | private String msg; | ||||
| //抖音支付方式 | |||||
| private Integer way; | |||||
| private Object data; | private Object data; | ||||
| //支付订单号 | |||||
| private String transactionId; | private String transactionId; | ||||
| private String openId; | |||||
| //支付时间 | |||||
| private Date payTime; | |||||
| private String endTimeStr; | private String endTimeStr; | ||||
| } | } | ||||
| @@ -29,6 +29,11 @@ public class WxH5PaySFTService extends BaseWxPaySFTAdapterService implements CDr | |||||
| return null; | return null; | ||||
| } | } | ||||
| @Override | |||||
| public PayAdapterResult createPay(ProductOrder order, WxAppinfo appInfo, WxPayAccount payAccount) throws Exception { | |||||
| return null; | |||||
| } | |||||
| @Override | @Override | ||||
| public PayQueryAdapterResult queryPayStatus(WxPayOrder oldRecord, WxAppinfo appInfo, | public PayQueryAdapterResult queryPayStatus(WxPayOrder oldRecord, WxAppinfo appInfo, | ||||
| WxPayAccount payAccount) throws Exception { | WxPayAccount payAccount) throws Exception { | ||||
| @@ -36,6 +41,11 @@ public class WxH5PaySFTService extends BaseWxPaySFTAdapterService implements CDr | |||||
| return null; | return null; | ||||
| } | } | ||||
| @Override | |||||
| public PayQueryAdapterResult queryPayStatus(ProductOrder order, WxAppinfo appInfo, WxPayAccount payAccount) throws Exception { | |||||
| return null; | |||||
| } | |||||
| @Override | @Override | ||||
| public int queryPayStatus(PayQueryAdapterResult statusObject, String orderOutNo) throws Exception { | public int queryPayStatus(PayQueryAdapterResult statusObject, String orderOutNo) throws Exception { | ||||
| //return super.queryPayStatus(statusObject, orderOutNo); | //return super.queryPayStatus(statusObject, orderOutNo); | ||||
| @@ -193,7 +193,12 @@ public class WxMiniAppPaySFTAdapterService extends BaseWxPaySFTAdapterService i | |||||
| // return getOrderPResult(response); | // return getOrderPResult(response); | ||||
| } | } | ||||
| } | } | ||||
| @Override | |||||
| public PayAdapterResult createPay(ProductOrder order, WxAppinfo appInfo, WxPayAccount payAccount) throws Exception { | |||||
| return null; | |||||
| } | |||||
| private PayQueryAdapterResult getPayCommonQueryResult(String response) { | private PayQueryAdapterResult getPayCommonQueryResult(String response) { | ||||
| JSONObject result = JSON.parseObject(response); | JSONObject result = JSON.parseObject(response); | ||||
| String transtionId = result.getString("transaction_id"); | 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 | @Override | ||||
| public int queryPayStatus(PayQueryAdapterResult statusObject, String orderOutNo) throws Exception { | public int queryPayStatus(PayQueryAdapterResult statusObject, String orderOutNo) throws Exception { | ||||
| return getPayCommonQueryResult((String)statusObject.getData()).getCode(); | return getPayCommonQueryResult((String)statusObject.getData()).getCode(); | ||||
| @@ -28,12 +28,22 @@ public class WxH5PayService extends BaseWxPayV2AdapterService implements CDrivi | |||||
| return null; | return null; | ||||
| } | } | ||||
| @Override | |||||
| public PayAdapterResult createPay(ProductOrder order, WxAppinfo appInfo, WxPayAccount payAccount) throws Exception { | |||||
| return null; | |||||
| } | |||||
| @Override | @Override | ||||
| public PayQueryAdapterResult queryPayStatus(WxPayOrder oldRecord, WxAppinfo appInfo, | public PayQueryAdapterResult queryPayStatus(WxPayOrder oldRecord, WxAppinfo appInfo, | ||||
| WxPayAccount payAccount) throws Exception { | WxPayAccount payAccount) throws Exception { | ||||
| return super.queryPayStatus(oldRecord, appInfo, payAccount); | return super.queryPayStatus(oldRecord, appInfo, payAccount); | ||||
| } | } | ||||
| @Override | |||||
| public PayQueryAdapterResult queryPayStatus(ProductOrder order, WxAppinfo appInfo, WxPayAccount payAccount) throws Exception { | |||||
| return null; | |||||
| } | |||||
| @Override | @Override | ||||
| public int queryPayStatus(PayQueryAdapterResult statusObject, String orderOutNo) throws Exception { | public int queryPayStatus(PayQueryAdapterResult statusObject, String orderOutNo) throws Exception { | ||||
| return super.queryPayStatus(statusObject, orderOutNo); | return super.queryPayStatus(statusObject, orderOutNo); | ||||
| @@ -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, | public PayQueryAdapterResult queryPayStatus(WxPayOrder oldRecord, WxAppinfo appInfo, | ||||
| WxPayAccount payAccount) throws Exception { | WxPayAccount payAccount) throws Exception { | ||||
| return super.queryPayStatus(oldRecord,appInfo, payAccount); | 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 { | public int queryPayStatus(PayQueryAdapterResult statusObject, String orderOutNo) throws Exception { | ||||
| return super.queryPayStatus(statusObject, orderOutNo); | return super.queryPayStatus(statusObject, orderOutNo); | ||||
| } | } | ||||
| @@ -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; | WxCUserMapper wxCUserMapper; | ||||
| @Autowired | @Autowired | ||||
| WxCUserService wxCUserService; | WxCUserService wxCUserService; | ||||
| @@ -250,7 +255,12 @@ public class WxMiniMaPayAdapterService extends BaseWxPayV2AdapterService impleme | |||||
| return super.queryPayStatus(oldRecord,appInfo, payAccount); | 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 { | public int queryPayStatus(PayQueryAdapterResult statusObject, String orderOutNo) throws Exception { | ||||
| return super.queryPayStatus(statusObject, orderOutNo); | return super.queryPayStatus(statusObject, orderOutNo); | ||||
| } | } | ||||
| @@ -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;//支付者 | |||||
| } | |||||
| @@ -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;//商户订单号 | |||||
| } | |||||
| @@ -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下的唯一标识 | |||||
| } | |||||
| @@ -9,6 +9,9 @@ import java.util.List; | |||||
| import java.util.Map; | import java.util.Map; | ||||
| import com.iformall.domain.po.*; | 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.apache.commons.lang3.StringUtils; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Service; | 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.ErrorCode; | ||||
| import com.iformall.common.Result; | import com.iformall.common.Result; | ||||
| import com.iformall.common.ResultData; | 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.exception.MallinkException; | ||||
| import com.iformall.pay.WxPay; | import com.iformall.pay.WxPay; | ||||
| import com.iformall.pay.WxPayOrderP; | 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.sft.entity.SFTPayerReq; | ||||
| import com.iformall.service.pay.service.pay.wx.v2.BaseWxPayV2AdapterService; | 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.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; | import lombok.extern.slf4j.Slf4j; | ||||
| @@ -109,8 +95,32 @@ public class WxMiniAppPayV3AdapterService extends BaseWxPayV3AdapterService impl | |||||
| return req; | 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(); | PayAdapterResult par = new PayAdapterResult(); | ||||
| if (StringUtils.isBlank(response)) { | if (StringUtils.isBlank(response)) { | ||||
| par.setSuccess(false); | par.setSuccess(false); | ||||
| @@ -124,15 +134,13 @@ public class WxMiniAppPayV3AdapterService extends BaseWxPayV3AdapterService impl | |||||
| }else { | }else { | ||||
| par.setSuccess(true); | par.setSuccess(true); | ||||
| par.setMsg("success."); | 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; | 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 timestamp = String.valueOf(Utility.getCurrentTimeStamp()); | ||||
| String noncestr = Utility.generate32UUID(); | String noncestr = Utility.generate32UUID(); | ||||
| String signAgent = WxPayV3.getMiniAppPayEntry(payService, appInfo.getAppId(), timestamp, noncestr, prepayId); | 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("package", "prepay_id=" + prepayId); | ||||
| returnMap.put("paySign", signAgent); | returnMap.put("paySign", signAgent); | ||||
| returnMap.put("signType", "RSA"); | returnMap.put("signType", "RSA"); | ||||
| returnMap.put("payOrderId", String.valueOf(record.getId())); | |||||
| returnMap.put("payOrderId", order_no); | |||||
| return returnMap; | return returnMap; | ||||
| } | } | ||||
| @@ -210,7 +218,7 @@ public class WxMiniAppPayV3AdapterService extends BaseWxPayV3AdapterService impl | |||||
| V3PayCommonMiniAppReq payReq = generatePayCommonRequest(payAccount,composeOrder,productName,record,openId,appInfo,currentDate); | V3PayCommonMiniAppReq payReq = generatePayCommonRequest(payAccount,composeOrder,productName,record,openId,appInfo,currentDate); | ||||
| try { | try { | ||||
| String response = WxPayV3.payCommonWithMiniApp(payService, payReq); | 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) { | }catch(WxPayException e) { | ||||
| log.error("wexin pay v3 error",e); | log.error("wexin pay v3 error",e); | ||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),e.getCustomErrorMsg()); | 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) { | private PayQueryAdapterResult getPayCommonQueryResult(String response) { | ||||
| JSONObject result = JSON.parseObject(response); | JSONObject result = JSON.parseObject(response); | ||||
| String transtionId = result.getString("transaction_id"); | 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); | PayQueryAdapterResult qresult = new PayQueryAdapterResult(payStatus.getCode(), tradeStateDesc,null, response,transtionId,successTime); | ||||
| return qresult; | 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) { | private PayQueryAdapterResult getPayCombineQueryResult(String response) { | ||||
| JSONObject result = JSON.parseObject(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 | @Override | ||||
| public int queryPayStatus(PayQueryAdapterResult statusObject, String orderOutNo) throws Exception { | public int queryPayStatus(PayQueryAdapterResult statusObject, String orderOutNo) throws Exception { | ||||
| return getPayCommonQueryResult((String)statusObject.getData()).getCode(); | return getPayCommonQueryResult((String)statusObject.getData()).getCode(); | ||||
| @@ -360,6 +360,20 @@ public class DateUtils { | |||||
| return formatter.format(date); | 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; | |||||
| } | |||||
| /** | /** | ||||
| * 获得当前时间前几天 | * 获得当前时间前几天 | ||||
| * | * | ||||
| @@ -0,0 +1,70 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||||
| <mapper namespace="com.iformall.mapper.ProductMapper"> | |||||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.Product"> | |||||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | |||||
| <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/> | |||||
| <result column="project_type" jdbcType="INTEGER" property="projectType" /> | |||||
| <result column="type" jdbcType="INTEGER" property="type" /> | |||||
| <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/> | |||||
| <result column="title" jdbcType="VARCHAR" property="title"/> | |||||
| <result column="en_title" jdbcType="VARCHAR" property="enTitle"/> | |||||
| <result column="glod" jdbcType="INTEGER" property="glod" /> | |||||
| <result column="detail" jdbcType="VARCHAR" property="detail"/> | |||||
| <result column="price_dollar" jdbcType="INTEGER" property="priceDollar" /> | |||||
| <result column="sell_price_dollar" jdbcType="INTEGER" property="sellPriceDollar" /> | |||||
| <result column="price_rmb" jdbcType="INTEGER" property="priceRmb" /> | |||||
| <result column="sell_price_rmb" jdbcType="INTEGER" property="sellPriceRmb" /> | |||||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | |||||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/> | |||||
| </resultMap> | |||||
| <sql id="allColumns"> | |||||
| `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` | |||||
| </sql> | |||||
| <sql id="dynamicWhereConditions"> | |||||
| where is_del = 0 | |||||
| <if test=" null != id "> and `id` = #{id} </if> | |||||
| <if test=" null != tenantId and '' != tenantId"> | |||||
| and `tenant_id` = #{tenantId} | |||||
| </if> | |||||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||||
| and `parent_tenant_id` = #{parentTenantId} | |||||
| </if> | |||||
| <if test=" null != projectType "> and `project_type` = #{projectType} </if> | |||||
| <if test=" null != type "> and `type` = #{type} </if> | |||||
| <if test=" null != title and '' != title"> | |||||
| and `title` like concat('%', #{title},'%') | |||||
| </if> | |||||
| <if test=" null != enTitle and '' != enTitle"> | |||||
| and `en_title` like concat('%', #{enTitle},'%') | |||||
| </if> | |||||
| <if test=" null != startDate "> | |||||
| and `create_date` >= #{startDate} | |||||
| </if> | |||||
| <if test=" null != endDate"> | |||||
| and `create_date` <= #{endDate} | |||||
| </if> | |||||
| <if test=" null != ids "> | |||||
| and id in | |||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||||
| #{idItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||||
| </sql> | |||||
| <select id="findList" parameterType="com.iformall.domain.po.Product" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns" /> | |||||
| from product | |||||
| <include refid="dynamicWhereConditions" /> | |||||
| </select> | |||||
| </mapper> | |||||
| @@ -0,0 +1,141 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||||
| <mapper namespace="com.iformall.mapper.ProductOrderMapper"> | |||||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.ProductOrder"> | |||||
| <id column="id" jdbcType="BIGINT" property="id"/> | |||||
| <result column="order_number" jdbcType="VARCHAR" property="orderNumber"/> | |||||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> | |||||
| <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" /> | |||||
| <result column="user_id" jdbcType="BIGINT" property="userId"/> | |||||
| <result column="product_id" jdbcType="BIGINT" property="productId"/> | |||||
| <result column="product_title" jdbcType="VARCHAR" property="productTitle"/> | |||||
| <result column="product_en_title" jdbcType="VARCHAR" property="productEnTitle"/> | |||||
| <result column="order_status" jdbcType="INTEGER" property="orderStatus"/> | |||||
| <result column="project_type" jdbcType="TINYINT" property="projectType"/> | |||||
| <result column="pay_vendor" jdbcType="TINYINT" property="payVendor" /> | |||||
| <result column="order_price" jdbcType="INTEGER" property="orderPrice"/> | |||||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/> | |||||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/> | |||||
| <result column="remark" jdbcType="VARCHAR" property="remark"/> | |||||
| <result column="order_id" jdbcType="VARCHAR" property="orderId"/> | |||||
| <result column="open_id" jdbcType="VARCHAR" property="openId"/> | |||||
| <result column="profit_sharing" jdbcType="INTEGER" property="profitSharing"/> | |||||
| <result column="transaction_id" jdbcType="VARCHAR" property="transactionId"/> | |||||
| <result column="payment" jdbcType="INTEGER" property="payment"/> | |||||
| <result column="payment_time" jdbcType="TIMESTAMP" property="paymentTime"/> | |||||
| <result column="pay_way" jdbcType="INTEGER" property="payWay"/> | |||||
| </resultMap> | |||||
| <sql id="allColumns"> | |||||
| `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` | |||||
| </sql> | |||||
| <sql id="dynamicWhereConditions"> | |||||
| where 1 = 1 | |||||
| <if test=" null != id "> | |||||
| and `id` = #{id} | |||||
| </if> | |||||
| <if test=" null != orderNumber "> | |||||
| and `order_number` = #{orderNumber} | |||||
| </if> | |||||
| <if test=" null != tenantId and '' != tenantId"> | |||||
| and `tenant_id` = #{tenantId} | |||||
| </if> | |||||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||||
| and `parent_tenant_id` = #{parentTenantId} | |||||
| </if> | |||||
| <if test=" null != userId "> | |||||
| and `user_id` = #{userId} | |||||
| </if> | |||||
| <if test=" null != productId "> | |||||
| and `product_id` = #{productId} | |||||
| </if> | |||||
| <if test=" null != productTitle and '' != productTitle"> | |||||
| and `product_title` like concat('%', #{productTitle},'%') | |||||
| </if> | |||||
| <if test=" null != productEnTitle and '' != productEnTitle"> | |||||
| and `product_en_title` like concat('%', #{productEnTitle},'%') | |||||
| </if> | |||||
| <if test=" null != projectType "> and `project_type` = #{projectType} </if> | |||||
| <if test=" null != payVendor "> and `pay_vendor` = #{payVendor} </if> | |||||
| <if test=" null != orderId "> | |||||
| and `order_id` = #{orderId} | |||||
| </if> | |||||
| <if test=" null != profitSharing "> | |||||
| and `profit_sharing` = #{profitSharing} | |||||
| </if> | |||||
| <if test=" null != transactionId "> | |||||
| and `transaction_id` = #{transactionId} | |||||
| </if> | |||||
| <if test=" null != orderStatus "> | |||||
| and `order_status` = #{orderStatus} | |||||
| </if> | |||||
| <if test=" null != startDate "> | |||||
| and `create_date` >= #{startDate} | |||||
| </if> | |||||
| <if test=" null != endDate"> | |||||
| and `create_date` <= #{endDate} | |||||
| </if> | |||||
| <if test=" null != payStartDate "> | |||||
| and `payment_time` >= #{payStartDate} | |||||
| </if> | |||||
| <if test=" null != payEndDate"> | |||||
| and `payment_time` <= #{payEndDate} | |||||
| </if> | |||||
| <if test=" null != statusS "> | |||||
| and `order_status` in | |||||
| <foreach collection="statusS" index="index" item="sItem" open="(" separator="," close=")"> | |||||
| #{sItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != ids "> | |||||
| and id in | |||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||||
| #{idItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != sortColumns">order by ${sortColumns}</if> | |||||
| </sql> | |||||
| <select id="findList" parameterType="com.iformall.domain.po.ProductOrder" resultMap="BaseResultMap"> | |||||
| select | |||||
| <include refid="allColumns"/> | |||||
| from product_order | |||||
| <include refid="dynamicWhereConditions"/> | |||||
| </select> | |||||
| <update id="orderPayUpdStatus" parameterType="com.iformall.domain.po.ProductOrder"> | |||||
| update product_order | |||||
| set `order_status` = #{orderStatus} | |||||
| ,`update_date` = #{updateDate} | |||||
| <if test=" null != openId"> | |||||
| ,`open_id` = #{openId} | |||||
| </if> | |||||
| <if test=" null != transactionId"> | |||||
| ,`transaction_id` = #{transactionId} | |||||
| </if> | |||||
| <if test=" null != paymentTime"> | |||||
| ,`payment_time` = #{paymentTime} | |||||
| </if> | |||||
| <if test=" null != payWay"> | |||||
| ,`pay_way` = #{payWay} | |||||
| </if> | |||||
| where id = #{id} and `order_status` != #{orderStatus} | |||||
| </update> | |||||
| </mapper> | |||||
| @@ -0,0 +1,58 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||||
| <mapper namespace="com.iformall.mapper.UserBasicFromMapper"> | |||||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.UserBasicFrom"> | |||||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | |||||
| <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/> | |||||
| <result column="from_project" jdbcType="INTEGER" property="fromProject" /> | |||||
| <result column="from_type" jdbcType="INTEGER" property="fromType" /> | |||||
| <result column="from_id" jdbcType="BIGINT" property="fromId" /> | |||||
| <result column="from_user_id" jdbcType="BIGINT" property="fromUserId" /> | |||||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | |||||
| </resultMap> | |||||
| <sql id="allColumns"> | |||||
| `id`,`tenant_id`,`parent_tenant_id`, | |||||
| `from_project`,`from_type`,`from_id`,`from_user_id`,`plat`, | |||||
| `create_date` | |||||
| </sql> | |||||
| <sql id="dynamicWhereConditions"> | |||||
| where 1 = 1 | |||||
| <if test=" null != id "> and `id` = #{id} </if> | |||||
| <if test=" null != tenantId and '' != tenantId"> | |||||
| and `tenant_id` = #{tenantId} | |||||
| </if> | |||||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||||
| and `parent_tenant_id` = #{parentTenantId} | |||||
| </if> | |||||
| <if test=" null != fromProject "> and `from_project` = #{fromProject} </if> | |||||
| <if test=" null != fromType "> and `from_type` = #{fromType} </if> | |||||
| <if test=" null != fromId "> and `from_id` = #{fromId} </if> | |||||
| <if test=" null != fromUserId "> and `from_user_id` = #{fromUserId} </if> | |||||
| <if test=" null != plat "> and `plat` = #{plat} </if> | |||||
| <if test=" null != startDate "> | |||||
| and `create_date` >= #{startDate} | |||||
| </if> | |||||
| <if test=" null != endDate"> | |||||
| and `create_date` <= #{endDate} | |||||
| </if> | |||||
| <if test=" null != ids "> | |||||
| and id in | |||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||||
| #{idItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||||
| </sql> | |||||
| <select id="findList" parameterType="com.iformall.domain.po.UserBasicFrom" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns" /> | |||||
| from user_basic_from | |||||
| <include refid="dynamicWhereConditions" /> | |||||
| </select> | |||||
| </mapper> | |||||
| @@ -0,0 +1,61 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||||
| <mapper namespace="com.iformall.mapper.UserBasicPropertyLogMapper"> | |||||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.UserBasicPropertyLog"> | |||||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | |||||
| <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/> | |||||
| <result column="user_id" jdbcType="BIGINT" property="userId" /> | |||||
| <result column="project_type" jdbcType="INTEGER" property="projectType" /> | |||||
| <result column="type" jdbcType="INTEGER" property="type" /> | |||||
| <result column="befour_gold" jdbcType="INTEGER" property="befourGold" /> | |||||
| <result column="gold_num" jdbcType="INTEGER" property="goldNum" /> | |||||
| <result column="after_gold" jdbcType="INTEGER" property="afterGold" /> | |||||
| <result column="extra_id" jdbcType="BIGINT" property="extraId" /> | |||||
| <result column="remark" jdbcType="VARCHAR" property="remark" /> | |||||
| <result column="detail" jdbcType="VARCHAR" property="detail" /> | |||||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | |||||
| </resultMap> | |||||
| <sql id="allColumns"> | |||||
| `id`,`tenant_id`,`parent_tenant_id`,`user_id`, | |||||
| `project_type`,`type`,`befour_gold`,`gold_num`,`after_gold`, | |||||
| `extra_id`,`remark`,`detail`,`create_date` | |||||
| </sql> | |||||
| <sql id="dynamicWhereConditions"> | |||||
| where 1 = 1 | |||||
| <if test=" null != id "> and `id` = #{id} </if> | |||||
| <if test=" null != tenantId and '' != tenantId"> | |||||
| and `tenant_id` = #{tenantId} | |||||
| </if> | |||||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||||
| and `parent_tenant_id` = #{parentTenantId} | |||||
| </if> | |||||
| <if test=" null != userId "> and `user_id` = #{userId} </if> | |||||
| <if test=" null != projectType "> and `project_type` = #{projectType} </if> | |||||
| <if test=" null != type "> and `type` = #{type} </if> | |||||
| <if test=" null != startDate "> | |||||
| and `create_date` >= #{startDate} | |||||
| </if> | |||||
| <if test=" null != endDate"> | |||||
| and `create_date` <= #{endDate} | |||||
| </if> | |||||
| <if test=" null != ids "> | |||||
| and id in | |||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||||
| #{idItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||||
| </sql> | |||||
| <select id="findList" parameterType="com.iformall.domain.po.UserBasicPropertyLog" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns" /> | |||||
| from user_basic_property_log | |||||
| <include refid="dynamicWhereConditions" /> | |||||
| </select> | |||||
| </mapper> | |||||
| @@ -0,0 +1,52 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||||
| <mapper namespace="com.iformall.mapper.UserBasicPropertyMapper"> | |||||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.UserBasicProperty"> | |||||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | |||||
| <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/> | |||||
| <result column="digital_avatar_glod" jdbcType="INTEGER" property="digitalAvatarGlod" /> | |||||
| <result column="digital_avatar_residue_glod" jdbcType="INTEGER" property="digitalAvatarResidueGlod" /> | |||||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/> | |||||
| </resultMap> | |||||
| <sql id="allColumns"> | |||||
| `id`,`tenant_id`,`parent_tenant_id`, | |||||
| `digital_avatar_glod`,`digital_avatar_residue_glod`, | |||||
| `update_date` | |||||
| </sql> | |||||
| <sql id="dynamicWhereConditions"> | |||||
| where 1 = 1 | |||||
| <if test=" null != id "> and `id` = #{id} </if> | |||||
| <if test=" null != tenantId and '' != tenantId"> | |||||
| and `tenant_id` = #{tenantId} | |||||
| </if> | |||||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||||
| and `parent_tenant_id` = #{parentTenantId} | |||||
| </if> | |||||
| <if test=" null != ids "> | |||||
| and id in | |||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||||
| #{idItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||||
| </sql> | |||||
| <select id="findList" parameterType="com.iformall.domain.po.UserBasicProperty" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns" /> | |||||
| from user_basic_property | |||||
| <include refid="dynamicWhereConditions" /> | |||||
| </select> | |||||
| <update id="addGlod" parameterType="com.iformall.domain.po.UserBasicProperty"> | |||||
| 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} | |||||
| </update> | |||||
| </mapper> | |||||
| @@ -15,6 +15,7 @@ | |||||
| <result column="last_token_time" jdbcType="TIMESTAMP" property="lastTokenTime"/> | <result column="last_token_time" jdbcType="TIMESTAMP" property="lastTokenTime"/> | ||||
| <result column="expires_in" jdbcType="INTEGER" property="expiresIn"/> | <result column="expires_in" jdbcType="INTEGER" property="expiresIn"/> | ||||
| <result column="pay_id" jdbcType="BIGINT" property="payId"/> | <result column="pay_id" jdbcType="BIGINT" property="payId"/> | ||||
| <result column="project_type" jdbcType="INTEGER" property="projectType"/> | |||||
| <result column="type" jdbcType="INTEGER" property="type"/> | <result column="type" jdbcType="INTEGER" property="type"/> | ||||
| <result column="mould_type" jdbcType="INTEGER" property="mouldType"/> | <result column="mould_type" jdbcType="INTEGER" property="mouldType"/> | ||||
| <result column="enable" jdbcType="INTEGER" property="enable"/> | <result column="enable" jdbcType="INTEGER" property="enable"/> | ||||
| @@ -30,7 +31,7 @@ | |||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| `id`,`tenant_id`,`app_id`,`parent_app_id`,`name`, | `id`,`tenant_id`,`app_id`,`parent_app_id`,`name`, | ||||
| `secret`,`token`,`aes_key`,`msg_data_format`,`access_token`,`last_token_time`,`expires_in`, | `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` | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||
| @@ -86,6 +87,9 @@ | |||||
| <if test=" null != payId "> | <if test=" null != payId "> | ||||
| and `pay_id` = #{payId} | and `pay_id` = #{payId} | ||||
| </if> | </if> | ||||
| <if test=" null != projectType "> | |||||
| and `project_type` = #{projectType} | |||||
| </if> | |||||
| <if test=" null != type "> | <if test=" null != type "> | ||||
| and `type` = #{type} | and `type` = #{type} | ||||
| </if> | </if> | ||||