| @@ -11,13 +11,18 @@ import com.iformall.domain.dto.OrderSaveDto; | |||
| import com.iformall.domain.po.*; | |||
| 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.enums.*; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.*; | |||
| import com.iformall.service.pay.PayServiceFactory; | |||
| import com.iformall.service.pay.entity.PayExtraParam; | |||
| import com.iformall.service.pay.service.pay.PayAdapterService; | |||
| import com.iformall.sm.AiDigitalAvatarHelper; | |||
| import com.iformall.sm.ShareImgParam; | |||
| import com.iformall.sm.ShareImgResult; | |||
| import com.iformall.utils.Base64Util; | |||
| import com.iformall.utils.Constant; | |||
| import com.iformall.utils.DateUtils; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| @@ -30,6 +35,7 @@ import org.springframework.web.bind.annotation.*; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import java.util.ArrayList; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| @@ -58,6 +64,9 @@ public class ProductOrderController extends BaseController { | |||
| @Autowired | |||
| PayServiceFactory payServiceFactory; | |||
| @Autowired | |||
| SchemeService schemeService; | |||
| @ApiOperation(value = "创建订单", notes = "") | |||
| @PostMapping("createOrder") | |||
| public ResultData createOrder(@RequestBody ProductOrder record) { | |||
| @@ -217,13 +226,53 @@ public class ProductOrderController extends BaseController { | |||
| @PostMapping("getPayUrl") | |||
| public ResultData getPayUrl(@RequestBody ProductOrder record) { | |||
| logger.debug("[" + getIpAddr() + "] ProductOrderController::getPayUrl"); | |||
| if(StringUtils.isBlank(record.getAppId())){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "appId 不能为空"); | |||
| } | |||
| WxAppinfo wxAppinfo = wxAppinfoService.getOnlyByAppIdFromRedis(record.getAppId()); | |||
| if(wxAppinfo == null){ | |||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | |||
| } | |||
| if(record.getUserId() == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"用户编号为空"); | |||
| } | |||
| WxCUserBasicInfo basicUser = wxCUserBasicInfoService.getById(record.getUserId()); | |||
| if(basicUser == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未查询到用户"); | |||
| } | |||
| return new ResultData(); | |||
| if(record.getProductId() == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"商品编号为空"); | |||
| } | |||
| Product product = productService.getById(record.getProductId()); | |||
| if(product == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未查询到商品"); | |||
| } | |||
| if(!wxAppinfo.getProjectType().equals(product.getProjectType())){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"商品数据异常"); | |||
| } | |||
| try { | |||
| EnumProject project = EnumProject.getEnum(wxAppinfo.getProjectType()); | |||
| EnumAppPlat plat = EnumAppPlat.getByCode(wxAppinfo.getPlat()); | |||
| String productScheme = Constant.mainPageUrl; | |||
| String sceneParam = "t:dt_p:"+record.getProductId()+"_u:"+record.getUserId(); | |||
| Date timeAfterDays = DateUtils.getTimeAfterDays(1, new Date()); | |||
| Long expireTime = timeAfterDays.getTime()/1000; | |||
| return schemeService.generateScheme(project,plat,productScheme,sceneParam,expireTime); | |||
| } catch (MallinkException e) { | |||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||
| }catch (Exception e) { | |||
| this.logger.error(e.getMessage(), e); | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR); | |||
| } | |||
| } | |||
| @AuthIgnore | |||
| @ApiOperation(value = "创建支付(不验证)", notes = "") | |||
| @ApiOperation(value = "创建支付(不验证用户)", notes = "") | |||
| @PostMapping("pay") | |||
| public ResultData pay(@RequestBody ProductOrder record) { | |||
| logger.debug("[" + getIpAddr() + "] ProductOrderController::pay"); | |||
| @@ -67,6 +67,9 @@ public class ProductOrder extends TenantEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value="支付渠道",name="payWay") | |||
| private Integer payWay; | |||
| @TableField(exist = false) | |||
| private String appId; | |||
| @TableField(exist = false) | |||
| protected List<Integer> statusS; | |||
| @@ -0,0 +1,28 @@ | |||
| package com.iformall.service; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.enums.EnumAppPlat; | |||
| import com.iformall.enums.EnumProject; | |||
| import com.iformall.exception.MallinkException; | |||
| import org.springframework.stereotype.Service; | |||
| import org.springframework.web.bind.annotation.RequestBody; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import java.util.Map; | |||
| @Service | |||
| public interface SchemeService { | |||
| /** | |||
| * 获取scheme码 | |||
| * @param project | |||
| * @param plat | |||
| * @param pageUrl | |||
| * @param sceneParam | |||
| * @return | |||
| */ | |||
| ResultData generateScheme(EnumProject project,EnumAppPlat plat,String pageUrl, String sceneParam,Long expireTime); | |||
| } | |||
| @@ -33,7 +33,9 @@ import java.util.*; | |||
| */ | |||
| @Service | |||
| public class QrCodeServiceImpl implements QrCodeService { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxAppinfoService wxAppinfoService; | |||
| @Autowired | |||
| @@ -0,0 +1,70 @@ | |||
| package com.iformall.service.impl; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxAppinfo; | |||
| import com.iformall.domain.po.WxPayAccount; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.enums.EnumAppPlat; | |||
| import com.iformall.enums.EnumProject; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.file.aliyun.AliyunOSS; | |||
| import com.iformall.service.QrCodeService; | |||
| import com.iformall.service.SchemeService; | |||
| import com.iformall.service.WxAppinfoService; | |||
| import com.iformall.service.WxPayAccountService; | |||
| import com.iformall.service.pay.PayServiceFactory; | |||
| import com.iformall.utils.QRCodeUtils; | |||
| 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 javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import java.io.File; | |||
| import java.io.FileInputStream; | |||
| import java.io.IOException; | |||
| import java.io.InputStream; | |||
| import java.util.Map; | |||
| /** | |||
| * @author | |||
| */ | |||
| @Service | |||
| public class SchemeServiceImpl implements SchemeService { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxAppinfoService wxAppinfoService; | |||
| @Autowired | |||
| private WxPayAccountService wxPayAccountService; | |||
| @Autowired | |||
| private PayServiceFactory payServiceFactory; | |||
| @Override | |||
| public ResultData generateScheme(EnumProject project, EnumAppPlat plat, String pageUrl, String sceneParam, Long expireTime) { | |||
| WxAppinfo appinfo = wxAppinfoService.getProjectCAppInfoFromRedis(project.getCode(),plat.getCode()); | |||
| if(appinfo == null){ | |||
| logger.error("获取scheme码{}未找到对应的小程序"); | |||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND.getCode(),"未找到程序应用"); | |||
| } | |||
| try { | |||
| String scheme = payServiceFactory.getQrcodeService(appinfo.getPlat()).getScheme(appinfo, pageUrl, sceneParam,expireTime); | |||
| return new ResultData(scheme); | |||
| } catch (WxErrorException e) { | |||
| logger.error("获取scheme码 error1" + e.getMessage()); | |||
| return new ResultData(ErrorCode.DEVICE_QRCODE_GET_FAILED.getCode(),e.getMessage()); | |||
| } catch (Exception e) { | |||
| logger.error("获取scheme码 error2" + e); | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR); | |||
| } | |||
| } | |||
| } | |||
| @@ -102,12 +102,19 @@ public interface PayAdapterService { | |||
| public PayAdapterResult payOrderPush(String openId,WxAppinfo appInfo, WxBatchOrder batchOrder,WxPayOrder payOrder) throws Exception; | |||
| /** | |||
| * 获取二维码 | |||
| * @param param | |||
| * 获取二维码 | |||
| * @param sceneParam | |||
| * @return | |||
| */ | |||
| public File getQrcode(WxAppinfo appinfo,String pageUrl,int type,String sceneParam) throws Exception; | |||
| /** | |||
| * 获取scheme码 | |||
| * @param sceneParam | |||
| * @return | |||
| */ | |||
| public String getScheme(WxAppinfo appinfo,String pageUrl,String sceneParam,Long expireTime) throws Exception; | |||
| /** | |||
| * 无需创建支付单返回 | |||
| * @param record | |||
| @@ -491,6 +491,11 @@ public class TtMiniAppPayAdapterService extends BaseTtPayAdapterService implemen | |||
| return super.getQrCode(appinfo, pageUrl, type, sceneParam); | |||
| } | |||
| @Override | |||
| public String getScheme(WxAppinfo appinfo, String pageUrl, String sceneParam, Long expireTime) throws Exception { | |||
| return null; | |||
| } | |||
| @Override | |||
| public PayAdapterResult noCreatePay(WxPayOrder record, WxComposeOrder composeOrder, List<WxOrder> childOrders) { | |||
| PayAdapterResult par = new PayAdapterResult(); | |||
| @@ -5,6 +5,7 @@ import java.util.Date; | |||
| import java.util.HashMap; | |||
| import java.util.Map; | |||
| import cn.binarywang.wx.miniapp.bean.scheme.WxMaGenerateSchemeRequest; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| @@ -103,6 +104,24 @@ public class BaseWxPayAdapterService { | |||
| return codeFile; | |||
| } | |||
| } | |||
| protected String generateScheme(WxAppinfo appinfo,String pageUrl,String sceneParam,Long expireTime) throws WxErrorException { | |||
| boolean isFmOpen = false; | |||
| WxMaService wxMaService; | |||
| if(isFmOpen) { | |||
| wxMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appinfo.getAppId()); | |||
| } else { | |||
| wxMaService = maUtil.getWeappService(appinfo); | |||
| } | |||
| WxMaGenerateSchemeRequest request = WxMaGenerateSchemeRequest.newBuilder() | |||
| .jumpWxa(WxMaGenerateSchemeRequest.JumpWxa.newBuilder().path(pageUrl).query(sceneParam).build()) | |||
| .isExpire(true) | |||
| .expireType(0) | |||
| .expireTime(expireTime) | |||
| .build(); | |||
| return wxMaService.getWxMaSchemeService().generate(request); | |||
| } | |||
| JSONObject errorMapClose = JSON.parseObject("{" + | |||
| "\"ORDERPAID\":{\"detail\":\"订单已支付\",\"reason\":\"订单已支付,不能发起关单\",\"resolution\":\"订单已支付,不能发起关单,请当作已支付的正常交易\"}," + | |||
| @@ -84,6 +84,11 @@ public class WxH5PaySFTService extends BaseWxPaySFTAdapterService implements CDr | |||
| return null; | |||
| } | |||
| @Override | |||
| public String getScheme(WxAppinfo appinfo, String pageUrl, String sceneParam, Long expireTime) throws Exception { | |||
| return null; | |||
| } | |||
| @Override | |||
| public PayAdapterResult noCreatePay(WxPayOrder record, WxComposeOrder composeOrder, List<WxOrder> childOrders) { | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR); | |||
| @@ -326,7 +326,12 @@ public class WxMiniAppPaySFTAdapterService extends BaseWxPaySFTAdapterService i | |||
| return super.getQrCode(appinfo, pageUrl, type, sceneParam); | |||
| } | |||
| @Override | |||
| @Override | |||
| public String getScheme(WxAppinfo appinfo, String pageUrl, String sceneParam, Long expireTime) throws Exception { | |||
| return null; | |||
| } | |||
| @Override | |||
| public PayAdapterResult noCreatePay(WxPayOrder record, WxComposeOrder composeOrder, List<WxOrder> childOrders) { | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR); | |||
| } | |||
| @@ -80,6 +80,11 @@ public class WxH5PayService extends BaseWxPayV2AdapterService implements CDrivi | |||
| return null; | |||
| } | |||
| @Override | |||
| public String getScheme(WxAppinfo appinfo, String pageUrl, String sceneParam, Long expireTime) throws Exception { | |||
| return null; | |||
| } | |||
| @Override | |||
| public PayAdapterResult noCreatePay(WxPayOrder record, WxComposeOrder composeOrder, List<WxOrder> childOrders) { | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR); | |||
| @@ -296,6 +296,11 @@ public class WxMiniAppPayAdapterService extends BaseWxPayV2AdapterService implem | |||
| return super.getQrCode(appinfo, pageUrl, type, sceneParam); | |||
| } | |||
| @Override | |||
| public String getScheme(WxAppinfo appinfo, String pageUrl, String sceneParam, Long expireTime) throws Exception { | |||
| return null; | |||
| } | |||
| @Override | |||
| public PayAdapterResult noCreatePay(WxPayOrder record, WxComposeOrder composeOrder, List<WxOrder> childOrders) { | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR); | |||
| @@ -292,6 +292,11 @@ public class WxMiniMaPayAdapterService extends BaseWxPayV2AdapterService impleme | |||
| return super.getQrCode(appinfo, pageUrl, type, sceneParam); | |||
| } | |||
| @Override | |||
| public String getScheme(WxAppinfo appinfo, String pageUrl, String sceneParam, Long expireTime) throws Exception { | |||
| return null; | |||
| } | |||
| @Override | |||
| public PayAdapterResult noCreatePay(WxPayOrder record, WxComposeOrder composeOrder, List<WxOrder> childOrders) { | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR); | |||
| @@ -450,7 +450,12 @@ public class WxMiniAppPayV3AdapterService extends BaseWxPayV3AdapterService impl | |||
| return super.getQrCode(appinfo, pageUrl, type, sceneParam); | |||
| } | |||
| @Override | |||
| @Override | |||
| public String getScheme(WxAppinfo appinfo, String pageUrl, String sceneParam,Long expireTime) throws Exception { | |||
| return super.generateScheme(appinfo, pageUrl, sceneParam,expireTime); | |||
| } | |||
| @Override | |||
| public PayAdapterResult noCreatePay(WxPayOrder record, WxComposeOrder composeOrder, List<WxOrder> childOrders) { | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR); | |||
| } | |||
| @@ -70,7 +70,7 @@ public class AiDigitalAvatarHelper { | |||
| // param.setCallback_url("https://phototest.metavatar.cc/C/callback/create/photo"); | |||
| param.setCallback_url(callbackUrl + "/callback/create/photo"); | |||
| // log.info("生成照片start request:" + param.getBg_img()); | |||
| // String response = HttpUtil.doAiVideoPost("http://nas.pucao.cn:2005/make_face", JSONObject.toJSONString(param)); | |||
| // String response = HttpUtil.doAiVideoPost("http://http://111.198.0.15:22200/make_face", JSONObject.toJSONString(param)); | |||
| String response = HttpUtil.doAiVideoPost(digital_avatar + "/make_face", JSONObject.toJSONString(param)); | |||
| log.info("生成照片end response:"); | |||
| @@ -183,21 +183,21 @@ public class AiDigitalAvatarHelper { | |||
| } | |||
| public static void main(String[] args) { | |||
| AiCheckPhotoParam param = new AiCheckPhotoParam(); | |||
| String img = Base64Util.imageUrlToBase64("https://suimang.oss-accelerate.aliyuncs.com/builtin/personmould/16760216806604820_cSHoijDX_grace_1080.jpg"); | |||
| param.setImg(img); | |||
| AiCheckPhotoResult result = AiDigitalAvatarHelper.checkPhoto(param); | |||
| System.out.println(result); | |||
| // DigitalAvatarParam param = new DigitalAvatarParam(); | |||
| // param.setBg_img("style_threeface"); | |||
| // AiCheckPhotoParam param = new AiCheckPhotoParam(); | |||
| // String img = Base64Util.imageUrlToBase64("https://suimang.oss-accelerate.aliyuncs.com/builtin/personmould/16760216806604820_cSHoijDX_grace_1080.jpg"); | |||
| // param.setImg_lift(img); | |||
| // param.setImg_middle(img); | |||
| // param.setImg_right(img); | |||
| // DigitalAvatarResult result = AiDigitalAvatarHelper.digitalAvatarPhoto(param,100001l); | |||
| // param.setImg(img); | |||
| // AiCheckPhotoResult result = AiDigitalAvatarHelper.checkPhoto(param); | |||
| // System.out.println(result); | |||
| DigitalAvatarParam param = new DigitalAvatarParam(); | |||
| param.setBg_img("素白"); | |||
| String img = Base64Util.imageUrlToBase64("https://suimang.oss-accelerate.aliyuncs.com/capi/2023-08-31/91f69a7fdac146159d2408baaad26619.jpg?x-oss-process=image/resize,w_10000/quality,q_60"); | |||
| param.setImg_lift(img); | |||
| param.setImg_middle("None"); | |||
| param.setImg_right("None"); | |||
| DigitalAvatarResult result = AiDigitalAvatarHelper.digitalAvatarPhoto(param,100001l); | |||
| System.out.println(result); | |||
| } | |||