| @@ -41,6 +41,7 @@ CREATE TABLE `user_basic_property_log` ( | |||||
| user_basic_image | user_basic_image | ||||
| user_digital_avatar_photo | |||||
| product | product | ||||
| product_order | product_order | ||||
| @@ -0,0 +1,156 @@ | |||||
| package com.iformall.controller; | |||||
| import com.alibaba.fastjson.JSONObject; | |||||
| 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.base.BaseEntity; | |||||
| import com.iformall.domain.po.sm.*; | |||||
| import com.iformall.enums.*; | |||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.service.sm.*; | |||||
| import com.iformall.video.VideoFactory; | |||||
| import com.iformall.video.entity.VideUploadResult; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import lombok.SneakyThrows; | |||||
| 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 javax.servlet.http.HttpServletRequest; | |||||
| import javax.servlet.http.HttpServletResponse; | |||||
| import java.io.File; | |||||
| import java.io.IOException; | |||||
| import java.io.InputStream; | |||||
| import java.io.OutputStream; | |||||
| import java.net.URL; | |||||
| import java.net.URLEncoder; | |||||
| import java.nio.charset.StandardCharsets; | |||||
| import java.util.Date; | |||||
| import java.util.List; | |||||
| @RestController | |||||
| @RequestMapping("/api/digitalAvatarPhoto") | |||||
| @Api(description = "模板接口") | |||||
| public class UserDigitalAvatarPhotoController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private UserDigitalAvatarOrderService userDigitalAvatarOrderService; | |||||
| @Autowired | |||||
| private UserDigitalAvatarPhotoService userDigitalAvatarPhotoService; | |||||
| @ApiOperation("制作照片") | |||||
| @PostMapping("createPhoto") | |||||
| public ResultData createPhoto(@RequestBody UserDigitalAvatarOrder record) { | |||||
| logger.debug("[" + getIpAddr() + "] UserDigitalAvatarPhotoController::createPhoto"); | |||||
| record.setUserId(getMemberId()); | |||||
| if(record.getId() != null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"参数异常"); | |||||
| } | |||||
| if(record.getDigitalAvatarId() == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"风格模板为空"); | |||||
| } | |||||
| return userDigitalAvatarOrderService.createOrder(record); | |||||
| } | |||||
| @ApiOperation("重复制作照片") | |||||
| @PostMapping("createPhotoAgain") | |||||
| public ResultData createPhotoAgain(@RequestBody UserDigitalAvatarOrder record) { | |||||
| logger.debug("[" + getIpAddr() + "] UserDigitalAvatarPhotoController::createPhotoAgain"); | |||||
| if(record.getId() == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"参数异常"); | |||||
| } | |||||
| record.setUserId(getMemberId()); | |||||
| UserDigitalAvatarOrder userDigitalAvatarOrder = userDigitalAvatarOrderService.selectById(record.getId()); | |||||
| if(userDigitalAvatarOrder == null || !record.getUserId().equals(userDigitalAvatarOrder.getUserId())){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未查询到订单"); | |||||
| } | |||||
| return userDigitalAvatarOrderService.createPhotoAgain(userDigitalAvatarOrder); | |||||
| } | |||||
| @ApiOperation("根据id查询接口") | |||||
| @GetMapping("/findById") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| public ResultData findById(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] UserDigitalAvatarPhotoController::findById"); | |||||
| if(id == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"参数为空"); | |||||
| } | |||||
| UserDigitalAvatarOrder userDigitalAvatarOrder = userDigitalAvatarOrderService.getById(id); | |||||
| if(userDigitalAvatarOrder == null || !getMemberId().equals(userDigitalAvatarOrder.getUserId())){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未查询到订单"); | |||||
| } | |||||
| return new ResultData(userDigitalAvatarOrder); | |||||
| } | |||||
| @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 UserDigitalAvatarOrder record, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] UserDigitalAvatarPhotoController::list"); | |||||
| if (record == null) record = new UserDigitalAvatarOrder(); | |||||
| record.setUserId(getMemberId()); | |||||
| record.setSortColumns(BaseEntity.SortField.UpdateDate_DESC); | |||||
| final PageInfo<UserDigitalAvatarOrder> page = userDigitalAvatarOrderService.cListAsPage(record, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("根据id删除接口") | |||||
| @PostMapping("/delete") | |||||
| public ResultData delete(@RequestBody UserDigitalAvatarOrder record) { | |||||
| logger.debug("[" + getIpAddr() + "] UserDigitalAvatarPhotoController::delete"); | |||||
| if(record.getId() == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"参数为空"); | |||||
| } | |||||
| UserDigitalAvatarOrder userDigitalAvatarOrder = userDigitalAvatarOrderService.selectById(record.getId()); | |||||
| if(userDigitalAvatarOrder == null || !getMemberId().equals(userDigitalAvatarOrder.getUserId())){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未查询到订单"); | |||||
| } | |||||
| userDigitalAvatarOrderService.deleteById(record.getId()); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("照片超分") | |||||
| @PostMapping("/photoSupper") | |||||
| public ResultData photoSupper(@RequestBody UserDigitalAvatarPhoto record) { | |||||
| logger.debug("[" + getIpAddr() + "] UserDigitalAvatarPhotoController::photoSupper"); | |||||
| if(record.getId() == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"参数为空"); | |||||
| } | |||||
| record.setUserId(getMemberId()); | |||||
| UserDigitalAvatarPhoto userDigitalAvatarPhoto = userDigitalAvatarPhotoService.selectById(record.getId()); | |||||
| if(userDigitalAvatarPhoto == null || !record.getUserId().equals(userDigitalAvatarPhoto.getUserId())){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未查询到照片"); | |||||
| } | |||||
| return userDigitalAvatarPhotoService.createPhotoSupper(userDigitalAvatarPhoto); | |||||
| } | |||||
| @ApiOperation("获取视频是否生成成功") | |||||
| @GetMapping("/getPhoto") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| public ResultData getPhoto(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] UserDigitalAvatarPhotoController::photoSupper"); | |||||
| if(id == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"参数为空"); | |||||
| } | |||||
| UserDigitalAvatarPhoto userDigitalAvatarPhoto = userDigitalAvatarPhotoService.selectById(id); | |||||
| if(userDigitalAvatarPhoto == null || !getMemberId().equals(userDigitalAvatarPhoto.getUserId())){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未查询到订单"); | |||||
| } | |||||
| return new ResultData(userDigitalAvatarPhoto); | |||||
| } | |||||
| } | |||||
| @@ -192,4 +192,5 @@ photo: | |||||
| url: http://111.198.0.15:22299 | url: http://111.198.0.15:22299 | ||||
| hy_url: http://111.198.0.15:22288 | hy_url: http://111.198.0.15:22288 | ||||
| talk: http://nas.pucao.cn:2001 | talk: http://nas.pucao.cn:2001 | ||||
| digital_avatar: http://nas.pucao.cn:2003 | |||||
| callbackUrl: https://phototest.metavatar.cc/C | callbackUrl: https://phototest.metavatar.cc/C | ||||
| @@ -449,6 +449,9 @@ public enum ErrorCode{ | |||||
| MEM_MONTH_IS_USED(13105, "该用户本月已领取或未到领取条件"), | MEM_MONTH_IS_USED(13105, "该用户本月已领取或未到领取条件"), | ||||
| GLOD_NOT_ENOUGH(13200, "金币不足"), | |||||
| /** | /** | ||||
| * 标签 | * 标签 | ||||
| */ | */ | ||||
| @@ -669,6 +672,11 @@ public enum ErrorCode{ | |||||
| TTCOUPON_IS_EMPTY(63000, "课程不存在"), | TTCOUPON_IS_EMPTY(63000, "课程不存在"), | ||||
| TTCOUPON_IS_TAKE_OFF(63001, "课程不在上架状态"), | TTCOUPON_IS_TAKE_OFF(63001, "课程不在上架状态"), | ||||
| /** | |||||
| * mould | |||||
| */ | |||||
| ORDER_CREAT_OVERRUN(64000, "重复生成次数超限"), | |||||
| ; | ; | ||||
| private int code; | private int code; | ||||
| @@ -27,4 +27,10 @@ public class UserBasicProperty extends TenantEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value="",name="updateDate") | @io.swagger.annotations.ApiModelProperty(value="",name="updateDate") | ||||
| private Date updateDate; | private Date updateDate; | ||||
| @TableField(exist = false) | |||||
| private Integer addGlod; | |||||
| @TableField(exist = false) | |||||
| private Integer reduceGlod; | |||||
| } | } | ||||
| @@ -85,9 +85,15 @@ public class DigitalAvatarMould extends TenantEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value="购买须知",name="remark") | @io.swagger.annotations.ApiModelProperty(value="购买须知",name="remark") | ||||
| private String remark; | private String remark; | ||||
| @io.swagger.annotations.ApiModelProperty(value="EnumDigitalAvatarMouldType",name="mouldType") | |||||
| private Integer mouldType; | |||||
| @io.swagger.annotations.ApiModelProperty(value="模板第三方Id",name="mouldSmId") | @io.swagger.annotations.ApiModelProperty(value="模板第三方Id",name="mouldSmId") | ||||
| private String mouldSmId; | private String mouldSmId; | ||||
| @io.swagger.annotations.ApiModelProperty(value="重试次数",name="againCount") | |||||
| private Integer againCount; | |||||
| @io.swagger.annotations.ApiModelProperty(value="EnumaMouldPatchStatus 状态",name="status") | @io.swagger.annotations.ApiModelProperty(value="EnumaMouldPatchStatus 状态",name="status") | ||||
| private Integer status; | private Integer status; | ||||
| @io.swagger.annotations.ApiModelProperty(value="上架时间",name="putonDate") | @io.swagger.annotations.ApiModelProperty(value="上架时间",name="putonDate") | ||||
| @@ -0,0 +1,86 @@ | |||||
| package com.iformall.domain.po.sm; | |||||
| import com.alibaba.fastjson.JSONObject; | |||||
| import com.baomidou.mybatisplus.annotation.TableField; | |||||
| import com.baomidou.mybatisplus.annotation.TableName; | |||||
| import com.iformall.common.SortColumn; | |||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import lombok.Data; | |||||
| import lombok.EqualsAndHashCode; | |||||
| import lombok.ToString; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import java.math.BigDecimal; | |||||
| import java.util.ArrayList; | |||||
| import java.util.Date; | |||||
| import java.util.List; | |||||
| @TableName(value = "user_digital_avatar_order") | |||||
| @Data | |||||
| @ToString(callSuper = true) | |||||
| @EqualsAndHashCode(callSuper = true) | |||||
| public class UserDigitalAvatarOrder extends TenantEntity { | |||||
| protected Long id; | |||||
| @TableField(exist = false) | |||||
| @io.swagger.annotations.ApiModelProperty(value="查询-创建起始时间",name="startDate") | |||||
| private Date startDate; | |||||
| @TableField(exist = false) | |||||
| @io.swagger.annotations.ApiModelProperty(value="查询-创建结束时间",name="endDate") | |||||
| private Date endDate; | |||||
| @io.swagger.annotations.ApiModelProperty(value="订单id",name="orderId") | |||||
| private Long orderId; | |||||
| @io.swagger.annotations.ApiModelProperty(value="用户Id",name="userId") | |||||
| private Long userId; | |||||
| @io.swagger.annotations.ApiModelProperty(value="",name="userImages") | |||||
| private String userImages; | |||||
| @TableField(exist = false) | |||||
| @io.swagger.annotations.ApiModelProperty(value="",name="userImageList") | |||||
| private List<String> userImageList; | |||||
| public List<String> getUserImageList(){ | |||||
| if(StringUtils.isNotBlank(userImages)){ | |||||
| try{ | |||||
| return JSONObject.parseArray(userImages, String.class); | |||||
| }catch(Exception e){ | |||||
| } | |||||
| } | |||||
| return new ArrayList<String>(); | |||||
| } | |||||
| @io.swagger.annotations.ApiModelProperty(value="",name="digitalAvatarId") | |||||
| private Long digitalAvatarId; | |||||
| @io.swagger.annotations.ApiModelProperty(value="EnumDigitalAvatarMouldType",name="digitalAvatarType") | |||||
| private Integer digitalAvatarType; | |||||
| @io.swagger.annotations.ApiModelProperty(value="模板",name="digitalAvatarSm") | |||||
| private String digitalAvatarSm; | |||||
| @io.swagger.annotations.ApiModelProperty(value="原价",name="price") | |||||
| private Integer price; | |||||
| @io.swagger.annotations.ApiModelProperty(value="名称",name="title") | |||||
| private String title; | |||||
| @io.swagger.annotations.ApiModelProperty(value="",name="remark") | |||||
| private String remark; | |||||
| @io.swagger.annotations.ApiModelProperty(value="EnumDigitalAvatarOrderStatus 状态",name="status") | |||||
| private Integer status; | |||||
| @io.swagger.annotations.ApiModelProperty(value="",name="msg") | |||||
| private String msg; | |||||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") | |||||
| private Date createDate; | |||||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") | |||||
| private Date updateDate; | |||||
| private List<UserDigitalAvatarPhoto> photoList; | |||||
| } | |||||
| @@ -0,0 +1,63 @@ | |||||
| package com.iformall.domain.po.sm; | |||||
| import com.alibaba.fastjson.JSONObject; | |||||
| import com.baomidou.mybatisplus.annotation.TableField; | |||||
| import com.baomidou.mybatisplus.annotation.TableName; | |||||
| import com.iformall.common.SortColumn; | |||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import com.iformall.enums.EnumSpeakType; | |||||
| import lombok.Data; | |||||
| import lombok.EqualsAndHashCode; | |||||
| import lombok.ToString; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import java.math.BigDecimal; | |||||
| import java.util.ArrayList; | |||||
| import java.util.Date; | |||||
| import java.util.List; | |||||
| @TableName(value = "user_digital_avatar_photo") | |||||
| @Data | |||||
| @ToString(callSuper = true) | |||||
| @EqualsAndHashCode(callSuper = true) | |||||
| public class UserDigitalAvatarPhoto extends TenantEntity { | |||||
| protected Long id; | |||||
| @TableField(exist = false) | |||||
| @io.swagger.annotations.ApiModelProperty(value="查询-创建起始时间",name="startDate") | |||||
| private Date startDate; | |||||
| @TableField(exist = false) | |||||
| @io.swagger.annotations.ApiModelProperty(value="查询-创建结束时间",name="endDate") | |||||
| private Date endDate; | |||||
| @io.swagger.annotations.ApiModelProperty(value="UserDigitalAvatarOrder.id",name="orderId") | |||||
| private Long orderId; | |||||
| @io.swagger.annotations.ApiModelProperty(value="用户Id",name="userId") | |||||
| private Long userId; | |||||
| @io.swagger.annotations.ApiModelProperty(value="",name="image") | |||||
| private String image; | |||||
| @io.swagger.annotations.ApiModelProperty(value="原价",name="price") | |||||
| private Integer price; | |||||
| @io.swagger.annotations.ApiModelProperty(value="",name="remark") | |||||
| private String remark; | |||||
| @io.swagger.annotations.ApiModelProperty(value="",name="imageSuper") | |||||
| private String imageSuper; | |||||
| @io.swagger.annotations.ApiModelProperty(value="EnumDigitalAvatarPhotoStatus 状态",name="status") | |||||
| private Integer status; | |||||
| @io.swagger.annotations.ApiModelProperty(value="",name="msg") | |||||
| private String msg; | |||||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") | |||||
| private Date createDate; | |||||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") | |||||
| private Date updateDate; | |||||
| } | |||||
| @@ -0,0 +1,49 @@ | |||||
| package com.iformall.enums; | |||||
| import java.util.ArrayList; | |||||
| import java.util.List; | |||||
| /** | |||||
| * | |||||
| */ | |||||
| public enum EnumDigitalAvatarMouldType { | |||||
| persion_1(1, "一人模板"), | |||||
| persion_2(2, "二人模板"), | |||||
| persion_3(3, "三人模板"), | |||||
| ; | |||||
| public static EnumDigitalAvatarMouldType getEnum(Integer code) { | |||||
| for (EnumDigitalAvatarMouldType value : values()) { | |||||
| if (value.getCode().equals(code)) { | |||||
| return value; | |||||
| } | |||||
| } | |||||
| return null; | |||||
| } | |||||
| public static List<Integer> getAllCodes(){ | |||||
| List<Integer> codes = new ArrayList<>(); | |||||
| for (EnumDigitalAvatarMouldType value : values()) { | |||||
| codes.add(value.getCode()); | |||||
| } | |||||
| return codes; | |||||
| } | |||||
| private Integer code; | |||||
| private String message; | |||||
| EnumDigitalAvatarMouldType(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; | |||||
| /** | |||||
| * | |||||
| */ | |||||
| public enum EnumDigitalAvatarOrderStatus { | |||||
| wait(1, "待制作"), | |||||
| finish(2, "制作完成"), | |||||
| fail(3, "制作失败"), | |||||
| ; | |||||
| public static EnumDigitalAvatarOrderStatus getEnum(Integer code) { | |||||
| for (EnumDigitalAvatarOrderStatus value : values()) { | |||||
| if (value.getCode().equals(code)) { | |||||
| return value; | |||||
| } | |||||
| } | |||||
| return null; | |||||
| } | |||||
| private Integer code; | |||||
| private String message; | |||||
| EnumDigitalAvatarOrderStatus(Integer code, String message) { | |||||
| this.code = code; | |||||
| this.message = message; | |||||
| } | |||||
| public Integer getCode() { | |||||
| return code; | |||||
| } | |||||
| public String getMessage() { | |||||
| return message; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,42 @@ | |||||
| package com.iformall.enums; | |||||
| import java.util.ArrayList; | |||||
| import java.util.List; | |||||
| /** | |||||
| * | |||||
| */ | |||||
| public enum EnumDigitalAvatarPhotoStatus { | |||||
| def(0, "默认"), | |||||
| wait(1, "待超分"), | |||||
| finish(2, "超分完成"), | |||||
| fail(3, "超分失败"), | |||||
| ; | |||||
| public static EnumDigitalAvatarPhotoStatus getEnum(Integer code) { | |||||
| for (EnumDigitalAvatarPhotoStatus value : values()) { | |||||
| if (value.getCode().equals(code)) { | |||||
| return value; | |||||
| } | |||||
| } | |||||
| return null; | |||||
| } | |||||
| private Integer code; | |||||
| private String message; | |||||
| EnumDigitalAvatarPhotoStatus(Integer code, String message) { | |||||
| this.code = code; | |||||
| this.message = message; | |||||
| } | |||||
| public Integer getCode() { | |||||
| return code; | |||||
| } | |||||
| public String getMessage() { | |||||
| return message; | |||||
| } | |||||
| } | |||||
| @@ -8,7 +8,11 @@ public enum EnumPropertyLogType { | |||||
| REGISTER(1,"注册"), | REGISTER(1,"注册"), | ||||
| INVITE(2,"邀请"), | INVITE(2,"邀请"), | ||||
| RECHARGE(3, "充值"), | RECHARGE(3, "充值"), | ||||
| CONSUMPTION(4, "消费"), | |||||
| // CONSUMPTION(4, "消费"), | |||||
| //智象 | |||||
| CONSUMPTION_10(10, "生成照片"), | |||||
| CONSUMPTION_11(11, "照片超分"), | |||||
| ; | ; | ||||
| public static EnumPropertyLogType getEnum(Integer code) { | public static EnumPropertyLogType getEnum(Integer code) { | ||||
| @@ -9,5 +9,8 @@ public interface UserBasicPropertyMapper extends CommonMapper<UserBasicProperty, | |||||
| List<UserBasicProperty> findList(UserBasicProperty record); | List<UserBasicProperty> findList(UserBasicProperty record); | ||||
| int addGlod(UserBasicProperty userBasicProperty); | |||||
| int addGlod(UserBasicProperty record); | |||||
| int reduceGlod(UserBasicProperty record); | |||||
| } | } | ||||
| @@ -0,0 +1,24 @@ | |||||
| package com.iformall.mapper; | |||||
| import com.iformall.common.CommonMapper; | |||||
| import com.iformall.domain.po.sm.UserDigitalAvatarOrder; | |||||
| import org.apache.ibatis.annotations.Param; | |||||
| import java.util.List; | |||||
| public interface UserDigitalAvatarOrderMapper extends CommonMapper<UserDigitalAvatarOrder, Long> { | |||||
| List<UserDigitalAvatarOrder> findList(UserDigitalAvatarOrder record); | |||||
| int deleteById(@Param("id")Long id); | |||||
| /** | |||||
| * c端列表查询,尽量减少字段 | |||||
| * @param record | |||||
| * @return | |||||
| */ | |||||
| List<UserDigitalAvatarOrder> findCList(UserDigitalAvatarOrder record); | |||||
| int findCount(@Param("orderId")Long orderId); | |||||
| } | |||||
| @@ -0,0 +1,22 @@ | |||||
| package com.iformall.mapper; | |||||
| import com.iformall.common.CommonMapper; | |||||
| import com.iformall.domain.po.sm.UserDigitalAvatarPhoto; | |||||
| import org.apache.ibatis.annotations.Param; | |||||
| import java.util.List; | |||||
| public interface UserDigitalAvatarPhotoMapper extends CommonMapper<UserDigitalAvatarPhoto, Long> { | |||||
| List<UserDigitalAvatarPhoto> findList(UserDigitalAvatarPhoto record); | |||||
| int deleteById(@Param("id")Long id); | |||||
| /** | |||||
| * c端列表查询,尽量减少字段 | |||||
| * @param record | |||||
| * @return | |||||
| */ | |||||
| List<UserDigitalAvatarPhoto> findCList(UserDigitalAvatarPhoto record); | |||||
| } | |||||
| @@ -4,6 +4,8 @@ import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.po.ProductOrder; | import com.iformall.domain.po.ProductOrder; | ||||
| import com.iformall.domain.po.UserBasicProperty; | import com.iformall.domain.po.UserBasicProperty; | ||||
| import java.util.Date; | |||||
| public interface UserBasicPropertyService { | public interface UserBasicPropertyService { | ||||
| /** | /** | ||||
| @@ -16,6 +18,24 @@ public interface UserBasicPropertyService { | |||||
| */ | */ | ||||
| PageInfo<UserBasicProperty> listAsPage(UserBasicProperty record, Integer pageIndex, Integer pageSize); | PageInfo<UserBasicProperty> listAsPage(UserBasicProperty record, Integer pageIndex, Integer pageSize); | ||||
| /** | |||||
| * 充值 | |||||
| * @param userId | |||||
| * @param projectType | |||||
| * @param extraId | |||||
| * @param glod | |||||
| */ | |||||
| void addRechargeGlod(Long userId, Integer projectType, Long extraId, Integer glod); | void addRechargeGlod(Long userId, Integer projectType, Long extraId, Integer glod); | ||||
| /** | |||||
| * 消费 | |||||
| * @param userId | |||||
| * @param projectType | |||||
| * @param propertyLogType | |||||
| * @param glod | |||||
| * @param extraId | |||||
| * @param now | |||||
| */ | |||||
| void consumptionGlod(Long userId, Integer projectType, Integer propertyLogType, Integer glod, Long extraId, Date now); | |||||
| } | } | ||||
| @@ -69,8 +69,7 @@ public class UserBasicPropertyServiceImpl implements UserBasicPropertyService { | |||||
| }else{ | }else{ | ||||
| befourGold = userBasicProperty.getDigitalAvatarResidueGlod(); | befourGold = userBasicProperty.getDigitalAvatarResidueGlod(); | ||||
| userBasicProperty.setDigitalAvatarGlod(glod); | |||||
| userBasicProperty.setDigitalAvatarResidueGlod(glod); | |||||
| userBasicProperty.setAddGlod(glod); | |||||
| userBasicProperty.setUpdateDate(now); | userBasicProperty.setUpdateDate(now); | ||||
| userBasicPropertyMapper.addGlod(userBasicProperty); | userBasicPropertyMapper.addGlod(userBasicProperty); | ||||
| } | } | ||||
| @@ -86,10 +85,44 @@ public class UserBasicPropertyServiceImpl implements UserBasicPropertyService { | |||||
| userBasicPropertyLog.setExtraId(extraId); | userBasicPropertyLog.setExtraId(extraId); | ||||
| userBasicPropertyLog.setCreateDate(now); | userBasicPropertyLog.setCreateDate(now); | ||||
| userBasicPropertyLogMapper.insert(userBasicPropertyLog); | userBasicPropertyLogMapper.insert(userBasicPropertyLog); | ||||
| } | } | ||||
| } | } | ||||
| @Override | |||||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||||
| public void consumptionGlod(Long userId, Integer projectType, Integer propertyLogType, Integer glod, Long extraId, Date now) { | |||||
| WxCUserBasicInfo basicInfo = wxCUserBasicInfoMapper.selectById(userId); | |||||
| if(basicInfo == null){ | |||||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY); | |||||
| } | |||||
| UserBasicProperty userBasicProperty = userBasicPropertyMapper.selectById(userId); | |||||
| if(userBasicProperty == null || userBasicProperty.getDigitalAvatarResidueGlod() < glod){ | |||||
| throw new MallinkException(ErrorCode.GLOD_NOT_ENOUGH); | |||||
| } | |||||
| UserBasicProperty updProperty = new UserBasicProperty(); | |||||
| updProperty.setId(userId); | |||||
| updProperty.setReduceGlod(glod); | |||||
| updProperty.setUpdateDate(now); | |||||
| int count = userBasicPropertyMapper.reduceGlod(updProperty); | |||||
| if(count != 1){ | |||||
| throw new MallinkException(ErrorCode.GLOD_NOT_ENOUGH.getCode(),"扣减异常"); | |||||
| } | |||||
| UserBasicPropertyLog userBasicPropertyLog = new UserBasicPropertyLog(); | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| userBasicPropertyLog.setId(idWorker.nextId()); | |||||
| userBasicPropertyLog.setUserId(userId); | |||||
| userBasicPropertyLog.setProjectType(projectType); | |||||
| userBasicPropertyLog.setType(propertyLogType); | |||||
| userBasicPropertyLog.setBefourGold(userBasicProperty.getDigitalAvatarResidueGlod()); | |||||
| userBasicPropertyLog.setGoldNum(glod); | |||||
| userBasicPropertyLog.setAfterGold(userBasicProperty.getDigitalAvatarResidueGlod()-glod); | |||||
| userBasicPropertyLog.setExtraId(extraId); | |||||
| userBasicPropertyLog.setCreateDate(now); | |||||
| userBasicPropertyLogMapper.insert(userBasicPropertyLog); | |||||
| } | |||||
| } | } | ||||
| @@ -0,0 +1,62 @@ | |||||
| package com.iformall.service.sm; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.po.sm.UserDigitalAvatarOrder; | |||||
| import com.iformall.domain.po.sm.UserDigitalAvatarPhoto; | |||||
| import java.util.List; | |||||
| import java.util.concurrent.Future; | |||||
| public interface UserDigitalAvatarOrderService { | |||||
| /** | |||||
| * 根据实体查询分页列表 | |||||
| * | |||||
| * @param record | |||||
| * @param pageIndex | |||||
| * @param pageSize | |||||
| * @return | |||||
| */ | |||||
| PageInfo<UserDigitalAvatarOrder> listAsPage(UserDigitalAvatarOrder record, Integer pageIndex, Integer pageSize); | |||||
| PageInfo<UserDigitalAvatarOrder> cListAsPage(UserDigitalAvatarOrder record, Integer pageIndex, Integer pageSize); | |||||
| List<UserDigitalAvatarOrder> findList(UserDigitalAvatarOrder record); | |||||
| /** | |||||
| * 根据Id获得实体 | |||||
| * | |||||
| * @param id | |||||
| * @return | |||||
| */ | |||||
| UserDigitalAvatarOrder selectById(Long id); | |||||
| UserDigitalAvatarOrder getById(Long id); | |||||
| /** | |||||
| * | |||||
| * @param record | |||||
| */ | |||||
| ResultData createOrder(UserDigitalAvatarOrder record); | |||||
| ResultData createPhotoAgain(UserDigitalAvatarOrder record); | |||||
| /** | |||||
| * 保存或更新实体 | |||||
| * | |||||
| * @param record | |||||
| */ | |||||
| void handleOrder(UserDigitalAvatarOrder record); | |||||
| /** | |||||
| * 根据Id删除实体 | |||||
| * | |||||
| * @param id | |||||
| */ | |||||
| void deleteById(Long id); | |||||
| void createPhoto(UserDigitalAvatarOrder record); | |||||
| } | |||||
| @@ -0,0 +1,19 @@ | |||||
| package com.iformall.service.sm; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.po.sm.UserDigitalAvatarPhoto; | |||||
| import java.util.List; | |||||
| public interface UserDigitalAvatarPhotoService { | |||||
| UserDigitalAvatarPhoto selectById(Long id); | |||||
| ResultData createPhotoSupper(UserDigitalAvatarPhoto record); | |||||
| void handleCreateSupper(UserDigitalAvatarPhoto record); | |||||
| void superPhoto(UserDigitalAvatarPhoto record); | |||||
| } | |||||
| @@ -0,0 +1,311 @@ | |||||
| package com.iformall.service.sm.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.UserBasicProperty; | |||||
| import com.iformall.domain.po.sm.DigitalAvatarMould; | |||||
| import com.iformall.domain.po.sm.UserDigitalAvatarOrder; | |||||
| import com.iformall.domain.po.sm.UserDigitalAvatarPhoto; | |||||
| import com.iformall.enums.*; | |||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.file.aliyun.AliyunOSS; | |||||
| import com.iformall.mapper.*; | |||||
| import com.iformall.service.UserBasicPropertyService; | |||||
| import com.iformall.service.impl.ProductOrderServiceImpl; | |||||
| import com.iformall.service.sm.UserDigitalAvatarOrderService; | |||||
| import com.iformall.service.sm.UserDigitalAvatarPhotoService; | |||||
| import com.iformall.sm.*; | |||||
| import com.iformall.utils.Base64Util; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.aop.framework.AopContext; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.beans.factory.annotation.Value; | |||||
| import org.springframework.scheduling.annotation.Async; | |||||
| import org.springframework.scheduling.annotation.AsyncResult; | |||||
| import org.springframework.stereotype.Service; | |||||
| import org.springframework.transaction.annotation.Propagation; | |||||
| import org.springframework.transaction.annotation.Transactional; | |||||
| import java.io.InputStream; | |||||
| import java.util.Date; | |||||
| import java.util.List; | |||||
| import java.util.concurrent.Future; | |||||
| @Service | |||||
| public class UserDigitalAvatarOrderServiceImpl implements UserDigitalAvatarOrderService { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| UserDigitalAvatarOrderMapper userDigitalAvatarOrderMapper; | |||||
| @Autowired | |||||
| UserDigitalAvatarPhotoMapper userDigitalAvatarPhotoMapper; | |||||
| @Autowired | |||||
| DigitalAvatarMouldMapper digitalAvatarMouldMapper; | |||||
| @Autowired | |||||
| UserBasicPropertyMapper userBasicPropertyMapper; | |||||
| @Autowired | |||||
| UserBasicPropertyService userBasicPropertyService; | |||||
| @Autowired | |||||
| private AliyunOSS aliyunOSS; | |||||
| private void handleOrderPhoto(List<UserDigitalAvatarOrder> list){ | |||||
| if(list == null || list.isEmpty()){ | |||||
| return; | |||||
| } | |||||
| for (UserDigitalAvatarOrder order: list) { | |||||
| if(EnumDigitalAvatarOrderStatus.finish.getCode().equals(order.getStatus())){ | |||||
| UserDigitalAvatarPhoto userDigitalAvatarPhotoQ = new UserDigitalAvatarPhoto(); | |||||
| userDigitalAvatarPhotoQ.setOrderId(order.getId()); | |||||
| List<UserDigitalAvatarPhoto> photoList = userDigitalAvatarPhotoMapper.findCList(userDigitalAvatarPhotoQ); | |||||
| order.setPhotoList(photoList); | |||||
| } | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public PageInfo<UserDigitalAvatarOrder> listAsPage(UserDigitalAvatarOrder record, Integer pageIndex, Integer pageSize) { | |||||
| PageInfo<UserDigitalAvatarOrder> pageInfo = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> userDigitalAvatarOrderMapper.findList(record)); | |||||
| handleOrderPhoto(pageInfo.getList()); | |||||
| return pageInfo; | |||||
| } | |||||
| @Override | |||||
| public PageInfo<UserDigitalAvatarOrder> cListAsPage(UserDigitalAvatarOrder record, Integer pageIndex, Integer pageSize) { | |||||
| PageInfo<UserDigitalAvatarOrder> pageInfo = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> userDigitalAvatarOrderMapper.findCList(record)); | |||||
| handleOrderPhoto(pageInfo.getList()); | |||||
| return pageInfo; | |||||
| } | |||||
| @Override | |||||
| public List<UserDigitalAvatarOrder> findList(UserDigitalAvatarOrder record) { | |||||
| return userDigitalAvatarOrderMapper.findList(record); | |||||
| } | |||||
| @Override | |||||
| public UserDigitalAvatarOrder selectById(Long id) { | |||||
| return userDigitalAvatarOrderMapper.selectById(id); | |||||
| } | |||||
| @Override | |||||
| public UserDigitalAvatarOrder getById(Long id) { | |||||
| UserDigitalAvatarOrder userDigitalAvatarOrder = userDigitalAvatarOrderMapper.selectById(id); | |||||
| if(userDigitalAvatarOrder != null && EnumDigitalAvatarOrderStatus.finish.getCode().equals(userDigitalAvatarOrder.getStatus())){ | |||||
| UserDigitalAvatarPhoto userDigitalAvatarPhotoQ = new UserDigitalAvatarPhoto(); | |||||
| userDigitalAvatarPhotoQ.setOrderId(userDigitalAvatarOrder.getId()); | |||||
| List<UserDigitalAvatarPhoto> photoList = userDigitalAvatarPhotoMapper.findList(userDigitalAvatarPhotoQ); | |||||
| userDigitalAvatarOrder.setPhotoList(photoList); | |||||
| } | |||||
| return userDigitalAvatarOrder; | |||||
| } | |||||
| @Override | |||||
| public ResultData createOrder(UserDigitalAvatarOrder record) { | |||||
| if(record.getUserId() == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未查询到用户"); | |||||
| } | |||||
| if(record.getDigitalAvatarId() == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"风格模板为空"); | |||||
| } | |||||
| if(StringUtils.isBlank(record.getUserImages())){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"照片为空"); | |||||
| } | |||||
| if(record.getUserImageList() == null || record.getUserImageList().isEmpty()){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"照片格式错误"); | |||||
| } | |||||
| DigitalAvatarMould digitalAvatarMould = digitalAvatarMouldMapper.selectById(record.getDigitalAvatarId()); | |||||
| if(digitalAvatarMould == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未查询到风格模板信息"); | |||||
| } | |||||
| record.setDigitalAvatarSm(digitalAvatarMould.getMouldSmId()); | |||||
| record.setDigitalAvatarType(digitalAvatarMould.getMouldType()); | |||||
| record.setPrice(digitalAvatarMould.getSalePrice()); | |||||
| if(record.getUserImageList().size() != record.getDigitalAvatarType()){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"照片格式错误"); | |||||
| } | |||||
| if(record.getPrice() > 0){ | |||||
| UserBasicProperty userBasicProperty = userBasicPropertyMapper.selectById(record.getUserId()); | |||||
| if(userBasicProperty == null || userBasicProperty.getDigitalAvatarResidueGlod() < record.getPrice()){ | |||||
| return new ResultData(ErrorCode.GLOD_NOT_ENOUGH); | |||||
| } | |||||
| } | |||||
| try{ | |||||
| UserDigitalAvatarOrderServiceImpl proxy = (UserDigitalAvatarOrderServiceImpl) AopContext.currentProxy(); | |||||
| proxy.handleOrder(record); | |||||
| proxy.createPhoto(record); | |||||
| return new ResultData(record); | |||||
| }catch(MallinkException e){ | |||||
| return new ResultData(e.getErrorCode(),e.getMessage()); | |||||
| }catch(Exception e){ | |||||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public ResultData createPhotoAgain(UserDigitalAvatarOrder record) { | |||||
| if(!EnumDigitalAvatarOrderStatus.finish.getCode().equals(record.getStatus())){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"订单状态异常"); | |||||
| } | |||||
| DigitalAvatarMould digitalAvatarMould = digitalAvatarMouldMapper.selectById(record.getDigitalAvatarId()); | |||||
| if(digitalAvatarMould == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未查询到风格模板信息"); | |||||
| } | |||||
| int count = userDigitalAvatarOrderMapper.findCount(record.getOrderId()); | |||||
| if(count >= digitalAvatarMould.getAgainCount()){ | |||||
| return new ResultData(ErrorCode.ORDER_CREAT_OVERRUN); | |||||
| } | |||||
| Date now = new Date(); | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| UserDigitalAvatarOrder newDigitalAvatarOrder = new UserDigitalAvatarOrder(); | |||||
| newDigitalAvatarOrder.setId(idWorker.nextId()); | |||||
| newDigitalAvatarOrder.setOrderId(record.getOrderId()); | |||||
| newDigitalAvatarOrder.setUserId(record.getUserId()); | |||||
| newDigitalAvatarOrder.setUserImages(record.getUserImages()); | |||||
| newDigitalAvatarOrder.setDigitalAvatarId(record.getDigitalAvatarId()); | |||||
| newDigitalAvatarOrder.setDigitalAvatarType(record.getDigitalAvatarType()); | |||||
| newDigitalAvatarOrder.setDigitalAvatarSm(record.getDigitalAvatarSm()); | |||||
| newDigitalAvatarOrder.setPrice(0); | |||||
| newDigitalAvatarOrder.setTitle(record.getTitle()); | |||||
| newDigitalAvatarOrder.setStatus(EnumDigitalAvatarOrderStatus.wait.getCode()); | |||||
| newDigitalAvatarOrder.setCreateDate(now); | |||||
| newDigitalAvatarOrder.setUpdateDate(now); | |||||
| userDigitalAvatarOrderMapper.insert(newDigitalAvatarOrder); | |||||
| try{ | |||||
| UserDigitalAvatarOrderServiceImpl proxy = (UserDigitalAvatarOrderServiceImpl) AopContext.currentProxy(); | |||||
| proxy.createPhoto(record); | |||||
| return new ResultData(record); | |||||
| }catch(MallinkException e){ | |||||
| return new ResultData(e.getErrorCode(),e.getMessage()); | |||||
| }catch(Exception e){ | |||||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||||
| public void handleOrder(UserDigitalAvatarOrder record) { | |||||
| Date now = new Date(); | |||||
| if(record.getPrice() > 0){ | |||||
| userBasicPropertyService.consumptionGlod(record.getUserId(),EnumProject.PROJECT_5.getCode(), EnumPropertyLogType.CONSUMPTION_10.getCode(), | |||||
| record.getPrice(),record.getId(),now); | |||||
| } | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| record.setId(idWorker.nextId()); | |||||
| record.setOrderId(record.getId()); | |||||
| record.setStatus(EnumDigitalAvatarOrderStatus.wait.getCode()); | |||||
| record.setCreateDate(now); | |||||
| record.setUpdateDate(now); | |||||
| userDigitalAvatarOrderMapper.insert(record); | |||||
| } | |||||
| @Override | |||||
| public void deleteById(Long id) { | |||||
| userDigitalAvatarOrderMapper.deleteById(id); | |||||
| } | |||||
| @Async | |||||
| @Override | |||||
| public void createPhoto(UserDigitalAvatarOrder record){ | |||||
| if(EnumDigitalAvatarOrderStatus.finish.getCode().equals(record.getStatus())){ | |||||
| return; | |||||
| } | |||||
| UserDigitalAvatarOrder updOrder = new UserDigitalAvatarOrder(); | |||||
| updOrder.setId(record.getId()); | |||||
| try{ | |||||
| DigitalAvatarParam param = new DigitalAvatarParam(); | |||||
| param.setBg_img(record.getDigitalAvatarSm()); | |||||
| if(EnumDigitalAvatarMouldType.persion_1.getCode().equals(record.getDigitalAvatarType())){ | |||||
| String imgUrl1 = record.getUserImageList().get(0); | |||||
| param.setImg_lift(Base64Util.imageUrlToBase64(imgUrl1)); | |||||
| param.setImg_middle("None"); | |||||
| param.setImg_right("None"); | |||||
| }else if(EnumDigitalAvatarMouldType.persion_2.getCode().equals(record.getDigitalAvatarType())){ | |||||
| String imgUrl1 = record.getUserImageList().get(0); | |||||
| String imgUrl2 = record.getUserImageList().get(1); | |||||
| param.setImg_lift(Base64Util.imageUrlToBase64(imgUrl1)); | |||||
| param.setImg_middle("None"); | |||||
| param.setImg_right(Base64Util.imageUrlToBase64(imgUrl2)); | |||||
| }else if(EnumDigitalAvatarMouldType.persion_3.getCode().equals(record.getDigitalAvatarType())){ | |||||
| String imgUrl1 = record.getUserImageList().get(0); | |||||
| String imgUrl2 = record.getUserImageList().get(1); | |||||
| String imgUrl3 = record.getUserImageList().get(2); | |||||
| param.setImg_lift(Base64Util.imageUrlToBase64(imgUrl1)); | |||||
| param.setImg_middle(Base64Util.imageUrlToBase64(imgUrl2)); | |||||
| param.setImg_right(Base64Util.imageUrlToBase64(imgUrl3)); | |||||
| }else{ | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"上传图片参数异常"); | |||||
| } | |||||
| DigitalAvatarResult result = AiDigitalAvatarHelper.digitalAvatarPhoto(param); | |||||
| if(result.isSuccess()){ | |||||
| UserDigitalAvatarOrderServiceImpl proxy = (UserDigitalAvatarOrderServiceImpl) AopContext.currentProxy(); | |||||
| proxy.handlePhoto(record,result.getImgList()); | |||||
| }else{ | |||||
| updOrder.setStatus(EnumDigitalAvatarOrderStatus.fail.getCode()); | |||||
| updOrder.setMsg(result.getMsg()); | |||||
| } | |||||
| }catch(MallinkException e){ | |||||
| e.printStackTrace(); | |||||
| updOrder.setStatus(EnumDigitalAvatarOrderStatus.fail.getCode()); | |||||
| updOrder.setMsg(e.getMessage()); | |||||
| } catch(Exception e){ | |||||
| e.printStackTrace(); | |||||
| updOrder.setStatus(EnumDigitalAvatarOrderStatus.fail.getCode()); | |||||
| updOrder.setMsg("未知错误,请稍后重试"); | |||||
| } | |||||
| updOrder.setUpdateDate(new Date()); | |||||
| userDigitalAvatarOrderMapper.updateById(updOrder); | |||||
| } | |||||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||||
| public void handlePhoto(UserDigitalAvatarOrder record,List<String> imgList){ | |||||
| Date now = new Date(); | |||||
| UserDigitalAvatarOrder updOrder = new UserDigitalAvatarOrder(); | |||||
| updOrder.setId(record.getId()); | |||||
| updOrder.setStatus(EnumDigitalAvatarOrderStatus.finish.getCode()); | |||||
| updOrder.setMsg("success"); | |||||
| updOrder.setUpdateDate(now); | |||||
| userDigitalAvatarOrderMapper.updateById(updOrder); | |||||
| try{ | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| for (String img: imgList) { | |||||
| InputStream inputStream = Base64Util.base2InputStream(img); | |||||
| String img_url = aliyunOSS.upload(record.getTenantId(), ".jpg", inputStream); | |||||
| UserDigitalAvatarPhoto userDigitalAvatarPhoto = new UserDigitalAvatarPhoto(); | |||||
| userDigitalAvatarPhoto.setId(idWorker.nextId()); | |||||
| userDigitalAvatarPhoto.setOrderId(record.getId()); | |||||
| userDigitalAvatarPhoto.setUserId(record.getUserId()); | |||||
| userDigitalAvatarPhoto.setImage(img_url); | |||||
| userDigitalAvatarPhoto.setStatus(EnumDigitalAvatarPhotoStatus.def.getCode()); | |||||
| userDigitalAvatarPhoto.setCreateDate(now); | |||||
| userDigitalAvatarPhoto.setUpdateDate(now); | |||||
| userDigitalAvatarPhotoMapper.insert(userDigitalAvatarPhoto); | |||||
| } | |||||
| }catch(Exception e){ | |||||
| throw new MallinkException(ErrorCode.PICTURE_ANALYZING_ERROR.getCode(),"上传图片异常"); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,131 @@ | |||||
| package com.iformall.service.sm.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.sm.*; | |||||
| import com.iformall.enums.*; | |||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.file.aliyun.AliyunOSS; | |||||
| import com.iformall.mapper.UserDigitalAvatarPhotoMapper; | |||||
| import com.iformall.service.UserBasicPropertyService; | |||||
| import com.iformall.service.sm.*; | |||||
| import com.iformall.sm.*; | |||||
| import com.iformall.utils.Base64Util; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.aop.framework.AopContext; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.beans.factory.annotation.Value; | |||||
| import org.springframework.scheduling.annotation.Async; | |||||
| import org.springframework.scheduling.annotation.AsyncResult; | |||||
| import org.springframework.stereotype.Service; | |||||
| import org.springframework.transaction.annotation.Propagation; | |||||
| import org.springframework.transaction.annotation.Transactional; | |||||
| import java.io.InputStream; | |||||
| import java.util.*; | |||||
| import java.util.concurrent.Future; | |||||
| @Service | |||||
| public class UserDigitalAvatarPhotoServiceImpl implements UserDigitalAvatarPhotoService { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| UserDigitalAvatarPhotoMapper userDigitalAvatarPhotoMapper; | |||||
| @Autowired | |||||
| UserBasicPropertyService userBasicPropertyService; | |||||
| @Autowired | |||||
| private AliyunOSS aliyunOSS; | |||||
| @Override | |||||
| public UserDigitalAvatarPhoto selectById(Long id) { | |||||
| return userDigitalAvatarPhotoMapper.selectById(id); | |||||
| } | |||||
| @Override | |||||
| public ResultData createPhotoSupper(UserDigitalAvatarPhoto record) { | |||||
| if(!EnumDigitalAvatarPhotoStatus.def.getCode().equals(record.getStatus())){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"照片状态异常"); | |||||
| } | |||||
| try{ | |||||
| UserDigitalAvatarPhotoServiceImpl proxy = (UserDigitalAvatarPhotoServiceImpl) AopContext.currentProxy(); | |||||
| proxy.handleCreateSupper(record); | |||||
| proxy.superPhoto(record); | |||||
| return new ResultData(record); | |||||
| }catch(MallinkException e){ | |||||
| return new ResultData(e.getErrorCode(),e.getMessage()); | |||||
| }catch(Exception e){ | |||||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||||
| public void handleCreateSupper(UserDigitalAvatarPhoto record){ | |||||
| Date now = new Date(); | |||||
| //todo 获取超分价格 | |||||
| Integer price = 0; | |||||
| record.setPrice(price); | |||||
| if(price > 0){ | |||||
| userBasicPropertyService.consumptionGlod(record.getUserId(),EnumProject.PROJECT_5.getCode(), EnumPropertyLogType.CONSUMPTION_11.getCode(), | |||||
| price,record.getId(),now); | |||||
| } | |||||
| UserDigitalAvatarPhoto updPhoto = new UserDigitalAvatarPhoto(); | |||||
| updPhoto.setId(record.getId()); | |||||
| updPhoto.setPrice(record.getPrice()); | |||||
| updPhoto.setStatus(EnumDigitalAvatarPhotoStatus.wait.getCode()); | |||||
| updPhoto.setUpdateDate(now); | |||||
| userDigitalAvatarPhotoMapper.updateById(updPhoto); | |||||
| record.setStatus(EnumDigitalAvatarPhotoStatus.wait.getCode()); | |||||
| record.setUpdateDate(now); | |||||
| } | |||||
| @Override | |||||
| public void superPhoto(UserDigitalAvatarPhoto record){ | |||||
| if(EnumDigitalAvatarPhotoStatus.finish.getCode().equals(record.getStatus())){ | |||||
| return; | |||||
| } | |||||
| UserDigitalAvatarPhoto updPhoto = new UserDigitalAvatarPhoto(); | |||||
| updPhoto.setId(record.getId()); | |||||
| try{ | |||||
| SuperImgParam param = new SuperImgParam(); | |||||
| param.setImg(Base64Util.imageUrlToBase64(record.getImage())); | |||||
| SuperImgResult result = AiDigitalAvatarHelper.superImg(param); | |||||
| if(result.isSuccess()){ | |||||
| InputStream inputStream = Base64Util.base2InputStream(result.getImg()); | |||||
| String img_url = aliyunOSS.upload(record.getTenantId(), ".jpg", inputStream); | |||||
| updPhoto.setImageSuper(img_url); | |||||
| updPhoto.setStatus(EnumDigitalAvatarPhotoStatus.finish.getCode()); | |||||
| updPhoto.setMsg("success"); | |||||
| }else{ | |||||
| updPhoto.setStatus(EnumDigitalAvatarOrderStatus.fail.getCode()); | |||||
| updPhoto.setMsg(result.getMsg()); | |||||
| } | |||||
| } catch(MallinkException e){ | |||||
| e.printStackTrace(); | |||||
| updPhoto.setStatus(EnumDigitalAvatarPhotoStatus.fail.getCode()); | |||||
| updPhoto.setMsg(e.getMessage()); | |||||
| } catch(Exception e){ | |||||
| e.printStackTrace(); | |||||
| updPhoto.setStatus(EnumDigitalAvatarPhotoStatus.fail.getCode()); | |||||
| updPhoto.setMsg("未知错误,请稍后重试"); | |||||
| } | |||||
| updPhoto.setUpdateDate(new Date()); | |||||
| userDigitalAvatarPhotoMapper.updateById(updPhoto); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,107 @@ | |||||
| package com.iformall.sm; | |||||
| import com.alibaba.fastjson.JSON; | |||||
| import com.alibaba.fastjson.JSONObject; | |||||
| import com.iformall.utils.HttpUtil; | |||||
| import lombok.extern.slf4j.Slf4j; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.springframework.beans.factory.annotation.Value; | |||||
| import org.springframework.stereotype.Component; | |||||
| import java.util.ArrayList; | |||||
| import java.util.List; | |||||
| @Slf4j | |||||
| @Component | |||||
| public class AiDigitalAvatarHelper { | |||||
| private static String digital_avatar; | |||||
| @Value("${photo.digital_avatar}") | |||||
| public void setDigitalAvatar(String digital_avatar){ | |||||
| this.digital_avatar = digital_avatar; | |||||
| } | |||||
| public static DigitalAvatarResult digitalAvatarPhoto(DigitalAvatarParam param) { | |||||
| // log.info("生成照片start request:" + param.getBg_img()); | |||||
| String response = HttpUtil.doAiVideoPost(digital_avatar + "/make_face", JSONObject.toJSONString(param)); | |||||
| log.info("生成照片end response:"+response); | |||||
| DigitalAvatarResult result = new DigitalAvatarResult(); | |||||
| if(StringUtils.isBlank(response)){ | |||||
| result.setSuccess(false); | |||||
| result.setMsg("[metavatar]请求异常,请稍后重试"); | |||||
| return result; | |||||
| } | |||||
| JSONObject jsonObject = JSON.parseObject(response); | |||||
| JSONObject status = jsonObject.getJSONObject("status"); | |||||
| Integer code = status.getInteger("code"); | |||||
| if(code == null){ | |||||
| result.setSuccess(false); | |||||
| result.setMsg("[metavatar]请求异常,请稍后重试"); | |||||
| return result; | |||||
| } | |||||
| if(code.intValue() == 1000){ | |||||
| result.setSuccess(true); | |||||
| result.setMsg("success"); | |||||
| JSONObject data = jsonObject.getJSONObject("data"); | |||||
| List<String> imgList = new ArrayList<>(); | |||||
| imgList.add(data.getString("img_0")); | |||||
| imgList.add(data.getString("img_1")); | |||||
| imgList.add(data.getString("img_2")); | |||||
| imgList.add(data.getString("img_3")); | |||||
| result.setImgList(imgList); | |||||
| }else{ | |||||
| result.setSuccess(false); | |||||
| result.setMsg("[metavatar]"+status.getString("msg")); | |||||
| } | |||||
| return result; | |||||
| } | |||||
| public static SuperImgResult superImg(SuperImgParam param) { | |||||
| // log.info("生成照片start request:" + param.getBg_img()); | |||||
| String response = HttpUtil.doAiVideoPost(digital_avatar + "/sr_img", JSONObject.toJSONString(param)); | |||||
| log.info("照片超分end response:"+response); | |||||
| SuperImgResult result = new SuperImgResult(); | |||||
| if(StringUtils.isBlank(response)){ | |||||
| result.setSuccess(false); | |||||
| result.setMsg("[metavatar]请求异常,请稍后重试"); | |||||
| return result; | |||||
| } | |||||
| JSONObject jsonObject = JSON.parseObject(response); | |||||
| JSONObject status = jsonObject.getJSONObject("status"); | |||||
| Integer code = status.getInteger("code"); | |||||
| if(code == null){ | |||||
| result.setSuccess(false); | |||||
| result.setMsg("[metavatar]请求异常,请稍后重试"); | |||||
| return result; | |||||
| } | |||||
| if(code.intValue() == 1000){ | |||||
| result.setSuccess(true); | |||||
| result.setMsg("success"); | |||||
| JSONObject data = jsonObject.getJSONObject("data"); | |||||
| result.setImg(data.getString("img")); | |||||
| }else{ | |||||
| result.setSuccess(false); | |||||
| result.setMsg("[metavatar]"+status.getString("msg")); | |||||
| } | |||||
| return result; | |||||
| } | |||||
| public static void main(String[] args) { | |||||
| } | |||||
| } | |||||
| @@ -36,16 +36,20 @@ public class AiVideoHelper { | |||||
| public void setUrl(String url){ | public void setUrl(String url){ | ||||
| this.url = url; | this.url = url; | ||||
| } | } | ||||
| private static String hy_url; | private static String hy_url; | ||||
| @Value("${photo.hy_url}") | @Value("${photo.hy_url}") | ||||
| public void setHyUrl(String hyUrl){ | public void setHyUrl(String hyUrl){ | ||||
| this.hy_url = hyUrl; | this.hy_url = hyUrl; | ||||
| } | } | ||||
| private static String talk_url; | private static String talk_url; | ||||
| @Value("${photo.talk}") | @Value("${photo.talk}") | ||||
| public void setTalkUrl(String talkUrl){ | public void setTalkUrl(String talkUrl){ | ||||
| this.talk_url = talkUrl; | this.talk_url = talkUrl; | ||||
| } | } | ||||
| public static String photo_speak_suffix = "/img_talking"; | public static String photo_speak_suffix = "/img_talking"; | ||||
| public static String image_quality_suffix = "/image_qualit"; | public static String image_quality_suffix = "/image_qualit"; | ||||
| public static String voice_preview = "/tts_wav"; | public static String voice_preview = "/tts_wav"; | ||||
| @@ -0,0 +1,18 @@ | |||||
| package com.iformall.sm; | |||||
| import com.alibaba.fastjson.JSON; | |||||
| import com.alibaba.fastjson.JSONObject; | |||||
| import lombok.Data; | |||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| @Data | |||||
| public class DigitalAvatarParam { | |||||
| private String bg_img; | |||||
| private String img_lift; | |||||
| private String img_middle; | |||||
| private String img_right; | |||||
| } | |||||
| @@ -0,0 +1,15 @@ | |||||
| package com.iformall.sm; | |||||
| import lombok.Data; | |||||
| import java.util.List; | |||||
| @Data | |||||
| public class DigitalAvatarResult { | |||||
| private boolean success; | |||||
| private String msg; | |||||
| private List<String> imgList; | |||||
| } | |||||
| @@ -0,0 +1,10 @@ | |||||
| package com.iformall.sm; | |||||
| import lombok.Data; | |||||
| @Data | |||||
| public class SuperImgParam { | |||||
| private String img; | |||||
| } | |||||
| @@ -0,0 +1,13 @@ | |||||
| package com.iformall.sm; | |||||
| import lombok.Data; | |||||
| @Data | |||||
| public class SuperImgResult { | |||||
| private boolean success; | |||||
| private String msg; | |||||
| private String img; | |||||
| } | |||||
| @@ -1,10 +1,12 @@ | |||||
| package com.iformall.utils; | package com.iformall.utils; | ||||
| import sun.misc.BASE64Decoder; | |||||
| import sun.misc.BASE64Encoder; | import sun.misc.BASE64Encoder; | ||||
| import java.io.*; | import java.io.*; | ||||
| import java.net.HttpURLConnection; | import java.net.HttpURLConnection; | ||||
| import java.net.URL; | import java.net.URL; | ||||
| import java.util.Base64; | |||||
| import java.util.regex.Matcher; | import java.util.regex.Matcher; | ||||
| import java.util.regex.Pattern; | import java.util.regex.Pattern; | ||||
| @@ -366,6 +368,41 @@ public class Base64Util { | |||||
| return null; | return null; | ||||
| } | } | ||||
| public static InputStream base2InputStream(String base64string) { | |||||
| ByteArrayInputStream stream = null; | |||||
| try { | |||||
| BASE64Decoder decoder = new BASE64Decoder(); | |||||
| byte[] bt = decoder.decodeBuffer(base64string); | |||||
| stream = new ByteArrayInputStream(bt); | |||||
| } catch (Exception e) { | |||||
| e.printStackTrace(); | |||||
| } | |||||
| return stream; | |||||
| } | |||||
| public static String getFormatName(byte[] bytes) { | |||||
| if (bytes == null || bytes.length < 2) { | |||||
| return null; | |||||
| } | |||||
| if ((bytes[0] & 0xFF) == 0x47 && (bytes[1] & 0xFF) == 0x49) { | |||||
| return "gif"; | |||||
| } | |||||
| if ((bytes[0] & 0xFF) == 0x89 && (bytes[1] & 0xFF) == 0x50) { | |||||
| return "png"; | |||||
| } | |||||
| if ((bytes[0] & 0xFF) == 0xFF && (bytes[1] & 0xFF) == 0xD8) { | |||||
| return "jpg"; | |||||
| } | |||||
| return null; | |||||
| } | |||||
| public static String getFormatNameFromBase64(String base64) { | |||||
| byte[] bytes = Base64.getDecoder().decode(base64); | |||||
| return getFormatName(bytes); | |||||
| } | |||||
| // /** | // /** | ||||
| // * 图片转字符串 | // * 图片转字符串 | ||||
| // * @param image 图片Buffer | // * @param image 图片Buffer | ||||
| @@ -15,7 +15,9 @@ | |||||
| <result column="price" jdbcType="INTEGER" property="price"/> | <result column="price" jdbcType="INTEGER" property="price"/> | ||||
| <result column="detail" jdbcType="VARCHAR" property="detail"/> | <result column="detail" jdbcType="VARCHAR" property="detail"/> | ||||
| <result column="remark" jdbcType="VARCHAR" property="remark"/> | <result column="remark" jdbcType="VARCHAR" property="remark"/> | ||||
| <result column="mould_type" jdbcType="INTEGER" property="mouldType"/> | |||||
| <result column="mould_sm_id" jdbcType="VARCHAR" property="mouldSmId"/> | <result column="mould_sm_id" jdbcType="VARCHAR" property="mouldSmId"/> | ||||
| <result column="again_count" jdbcType="INTEGER" property="againCount"/> | |||||
| <result column="status" jdbcType="INTEGER" property="status"/> | <result column="status" jdbcType="INTEGER" property="status"/> | ||||
| <result column="puton_date" jdbcType="TIMESTAMP" property="putonDate"/> | <result column="puton_date" jdbcType="TIMESTAMP" property="putonDate"/> | ||||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/> | <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/> | ||||
| @@ -25,7 +27,7 @@ | |||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| `id`, `tenant_id`, `parent_tenant_id`, `cover_img`, `cover_picture`, `detail_picture`, | `id`, `tenant_id`, `parent_tenant_id`, `cover_img`, `cover_picture`, `detail_picture`, | ||||
| `title`, `sub_title`, `scene_sign`, `sale_price`, `price`, | `title`, `sub_title`, `scene_sign`, `sale_price`, `price`, | ||||
| `detail`, `remark`, `mould_sm_id`, | |||||
| `detail`, `remark`, `mould_type`, `mould_sm_id`, `again_count`, | |||||
| `status`, `puton_date`, `create_date`, `update_date` | `status`, `puton_date`, `create_date`, `update_date` | ||||
| </sql> | </sql> | ||||
| @@ -47,20 +49,12 @@ | |||||
| and `title` like concat('%', #{title},'%') | and `title` like concat('%', #{title},'%') | ||||
| </if> | </if> | ||||
| <if test=" null != subTitle "> | |||||
| and `sub_title` like concat('%', #{subTitle},'%') | |||||
| </if> | |||||
| <if test=" null != sceneSign and '' != sceneSign"> | <if test=" null != sceneSign and '' != sceneSign"> | ||||
| and JSON_CONTAINS(scene_sign,json_array(#{sceneSign})) | and JSON_CONTAINS(scene_sign,json_array(#{sceneSign})) | ||||
| </if> | </if> | ||||
| <if test=" null != salePrice "> | |||||
| and `sale_price` = #{salePrice} | |||||
| </if> | |||||
| <if test=" null != price "> | |||||
| and `price` = #{price} | |||||
| <if test=" null != mouldType"> | |||||
| and `mould_type` = #{mouldType} | |||||
| </if> | </if> | ||||
| <if test=" null != status"> | <if test=" null != status"> | ||||
| @@ -99,7 +93,7 @@ | |||||
| select | select | ||||
| `id`, `cover_img`, `cover_picture`, | `id`, `cover_img`, `cover_picture`, | ||||
| `title`, `sub_title`, `scene_sign`, `sale_price`, `price`, | `title`, `sub_title`, `scene_sign`, `sale_price`, `price`, | ||||
| `mould_sm_id`, | |||||
| `mould_type`, `mould_sm_id`, | |||||
| `status`, `create_date`, `update_date` | `status`, `create_date`, `update_date` | ||||
| from digital_avatar_mould | from digital_avatar_mould | ||||
| <include refid="dynamicWhereConditions"/> | <include refid="dynamicWhereConditions"/> | ||||
| @@ -44,9 +44,17 @@ | |||||
| <update id="addGlod" parameterType="com.iformall.domain.po.UserBasicProperty"> | <update id="addGlod" parameterType="com.iformall.domain.po.UserBasicProperty"> | ||||
| update user_basic_property | update user_basic_property | ||||
| set `update_date` = #{updateDate} | set `update_date` = #{updateDate} | ||||
| ,`digital_avatar_glod` = digital_avatar_glod+#{digitalAvatarGlod} | |||||
| ,`digital_avatar_residue_glod` = digital_avatar_residue_glod+#{digitalAvatarResidueGlod} | |||||
| ,`digital_avatar_glod` = digital_avatar_glod+#{addGlod} | |||||
| ,`digital_avatar_residue_glod` = digital_avatar_residue_glod+#{addGlod} | |||||
| where id = #{id} | where id = #{id} | ||||
| </update> | </update> | ||||
| <update id="reduceGlod" parameterType="com.iformall.domain.po.UserBasicProperty"> | |||||
| update user_basic_property | |||||
| set `update_date` = #{updateDate} | |||||
| ,`digital_avatar_residue_glod` = digital_avatar_residue_glod-#{reduceGlod} | |||||
| where id = #{id} | |||||
| and digital_avatar_residue_glod >= #{reduceGlod} | |||||
| </update> | |||||
| </mapper> | </mapper> | ||||
| @@ -0,0 +1,111 @@ | |||||
| <?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.UserDigitalAvatarOrderMapper"> | |||||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.sm.UserDigitalAvatarOrder"> | |||||
| <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="order_id" jdbcType="BIGINT" property="orderId"/> | |||||
| <result column="user_id" jdbcType="BIGINT" property="userId"/> | |||||
| <result column="user_images" jdbcType="VARCHAR" property="userImages"/> | |||||
| <result column="digital_avatar_id" jdbcType="BIGINT" property="digitalAvatarId"/> | |||||
| <result column="digital_avatar_type" jdbcType="INTEGER" property="digitalAvatarType"/> | |||||
| <result column="digital_avatar_sm" jdbcType="VARCHAR" property="digitalAvatarSm"/> | |||||
| <result column="price" jdbcType="INTEGER" property="price"/> | |||||
| <result column="title" jdbcType="VARCHAR" property="title"/> | |||||
| <result column="remark" jdbcType="VARCHAR" property="remark"/> | |||||
| <result column="status" jdbcType="INTEGER" property="status"/> | |||||
| <result column="msg" jdbcType="VARCHAR" property="msg"/> | |||||
| <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`, `order_id`, `user_id`, | |||||
| `user_images`, `digital_avatar_id`, `digital_avatar_type`, `digital_avatar_sm`, `price`, | |||||
| `title`, `remark`, `status`, `msg`, `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 != orderId "> | |||||
| and `order_id` = #{orderId} | |||||
| </if> | |||||
| <if test=" null != userId "> | |||||
| and `user_id` = #{userId} | |||||
| </if> | |||||
| <if test=" null != digitalAvatarId "> | |||||
| and `digital_avatar_id` = #{digitalAvatarId} | |||||
| </if> | |||||
| <if test=" null != digitalAvatarType "> | |||||
| and `digital_avatar_type` = #{digitalAvatarType} | |||||
| </if> | |||||
| <if test=" null != title and ''!=title"> | |||||
| and `title` like concat('%', #{title},'%') | |||||
| </if> | |||||
| <if test=" null != videoStatus "> | |||||
| and `status` = #{status} | |||||
| </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.sm.UserDigitalAvatarOrder" resultMap="BaseResultMap"> | |||||
| select | |||||
| <include refid="allColumns"/> | |||||
| from user_digital_avatar_order | |||||
| <include refid="dynamicWhereConditions"/> | |||||
| </select> | |||||
| <delete id="deleteById" parameterType="java.util.HashMap"> | |||||
| update user_digital_avatar_order set is_del = 1,update_date = now() where id = #{id} | |||||
| </delete> | |||||
| <select id="findCList" parameterType="com.iformall.domain.po.sm.UserDigitalAvatarOrder" resultMap="BaseResultMap"> | |||||
| select | |||||
| `id`, `order_id`, | |||||
| `digital_avatar_type`, | |||||
| `title`, `remark`, `status`, `msg`,`create_date`, `update_date` | |||||
| from user_digital_avatar_order | |||||
| <include refid="dynamicWhereConditions"/> | |||||
| </select> | |||||
| <select id="findCount" parameterType="java.util.HashMap" resultType="Integer"> | |||||
| select count(1) | |||||
| from user_digital_avatar_order | |||||
| where `order_id` = #{orderId} | |||||
| </select> | |||||
| </mapper> | |||||
| @@ -0,0 +1,90 @@ | |||||
| <?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.UserDigitalAvatarPhotoMapper"> | |||||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.sm.UserDigitalAvatarPhoto"> | |||||
| <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="order_id" jdbcType="BIGINT" property="orderId"/> | |||||
| <result column="user_id" jdbcType="BIGINT" property="userId"/> | |||||
| <result column="image" jdbcType="VARCHAR" property="image"/> | |||||
| <result column="price" jdbcType="INTEGER" property="price"/> | |||||
| <result column="remark" jdbcType="VARCHAR" property="remark"/> | |||||
| <result column="image_super" jdbcType="VARCHAR" property="imageSuper"/> | |||||
| <result column="status" jdbcType="INTEGER" property="status"/> | |||||
| <result column="msg" jdbcType="VARCHAR" property="msg"/> | |||||
| <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`, `order_id`, `user_id`, | |||||
| `image`, `price`, | |||||
| `remark`,`image_super`, `status`, `msg`, `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 != orderId "> | |||||
| and `order_id` = #{orderId} | |||||
| </if> | |||||
| <if test=" null != userId "> | |||||
| and `user_id` = #{userId} | |||||
| </if> | |||||
| <if test=" null != videoStatus "> | |||||
| and `status` = #{status} | |||||
| </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.sm.UserDigitalAvatarPhoto" resultMap="BaseResultMap"> | |||||
| select | |||||
| <include refid="allColumns"/> | |||||
| from user_digital_avatar_photo | |||||
| <include refid="dynamicWhereConditions"/> | |||||
| </select> | |||||
| <delete id="deleteById" parameterType="java.util.HashMap"> | |||||
| update user_digital_avatar_photo set is_del = 1,update_date = now() where id = #{id} | |||||
| </delete> | |||||
| <select id="findCList" parameterType="com.iformall.domain.po.sm.UserDigitalAvatarPhoto" resultMap="BaseResultMap"> | |||||
| select | |||||
| `id`, `order_id`, | |||||
| `image`, | |||||
| `image_super`, `status`, `msg`, `create_date`, `update_date` | |||||
| from user_digital_avatar_photo | |||||
| <include refid="dynamicWhereConditions"/> | |||||
| </select> | |||||
| </mapper> | |||||