| @@ -77,7 +77,7 @@ public class VideoController extends BaseController { | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "title", value = "页数", dataType = "String", paramType = "query", required = true)}) | |||
| public ResultData list(@ModelAttribute WxPropertyContract wxPropertyContract, String title) { | |||
| VideUploadResult result = videoFactory.getExcutor(videoType).uploadLocalVideo("123123213", "/root/111.mp4"); | |||
| VideUploadResult result = videoFactory.getExcutor(videoType).uploadLocalVideo("123123213", "C:\\Users\\xiaohu\\Desktop\\111.mp4"); | |||
| return new ResultData(result); | |||
| } | |||
| @@ -93,7 +93,18 @@ public class VideoController extends BaseController { | |||
| public ResultData upload(@RequestParam("file") MultipartFile multiReq,@RequestParam Map<String, String> param) { | |||
| try { | |||
| String title = param.get("title"); | |||
| VideUploadResult result = videoFactory.getExcutor(videoType).uploadLocalVideo(title, multiReq.getInputStream()); | |||
| int dot = multiReq.getOriginalFilename().lastIndexOf('.'); | |||
| String fileFormat = ""; | |||
| if (dot >= 0) { | |||
| fileFormat = multiReq.getOriginalFilename().substring(dot, multiReq.getOriginalFilename().length()); | |||
| if(StringUtils.isBlank(title)){ | |||
| title = multiReq.getOriginalFilename().substring(0,dot); | |||
| } | |||
| } | |||
| if(!fileFormat.endsWith("mp4")){ | |||
| return new ResultData(ErrorCode.PICTURE_ENDWIDTH_ERROR); | |||
| } | |||
| VideUploadResult result = videoFactory.getExcutor(videoType).uploadLocalVideo(title, multiReq.getInputStream(),fileFormat); | |||
| return new ResultData(result); | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| @@ -22,7 +22,8 @@ public class UrlCheck { | |||
| || url.contains("/kwMeter/import") | |||
| || url.contains("/wxImportTemplate/importTemplate") | |||
| || url.contains("/invest/customer/importCustomer") | |||
| || url.contains("/alipay/imageUpload"); | |||
| || url.contains("/alipay/imageUpload") | |||
| || url.contains("/video/upload"); | |||
| } | |||
| } | |||
| @@ -32,6 +32,16 @@ public class AppTest { | |||
| * 注册并查询用户详细信息 参数 | |||
| */ | |||
| // paramMap.put("phone","18872592633"); | |||
| // paramMap.put("nickName","周小菇凉"); | |||
| // paramMap.put("sex","1"); | |||
| // paramMap.put("avatarUrl",""); | |||
| /** | |||
| * 查询用户详细信息 参数 | |||
| */ | |||
| // paramMap.put("phone","18872592633"); | |||
| paramMap.put("openId","opvcM5A41kbQF_NY8k3LMDqxCDUM"); | |||
| /** | |||
| * 创建交易信息 参数 | |||
| @@ -59,15 +69,15 @@ public class AppTest { | |||
| /** | |||
| * 积分抵扣 参数 | |||
| */ | |||
| IdWorker idWorker = IdWorker.get(); | |||
| paramMap.put("transactionId",String.valueOf(idWorker.nextId()));//***订单Id | |||
| paramMap.put("shopNumber","1001");//***门店唯一标识 对应双方平台门店 | |||
| paramMap.put("shopName","百丽");//门店名称 | |||
| paramMap.put("userNumber","546907706202185728");//***会员Id546907706202185728 | |||
| paramMap.put("userPhone","18872592633");//会员手机号 | |||
| paramMap.put("timeEnd","2021-04-26 11:43:00");//***积分抵扣时间 | |||
| paramMap.put("amount","100");//***付款金额(分) | |||
| paramMap.put("summary","我要换东西");//付款摘要 | |||
| // IdWorker idWorker = IdWorker.get(); | |||
| // paramMap.put("transactionId",String.valueOf(idWorker.nextId()));//***订单Id | |||
| // paramMap.put("shopNumber","1001");//***门店唯一标识 对应双方平台门店 | |||
| // paramMap.put("shopName","百丽");//门店名称 | |||
| // paramMap.put("userNumber","546907706202185728");//***会员Id546907706202185728 | |||
| // paramMap.put("userPhone","18872592633");//会员手机号 | |||
| // paramMap.put("timeEnd","2021-04-26 11:43:00");//***积分抵扣时间 | |||
| // paramMap.put("amount","100");//***付款金额(分) | |||
| // paramMap.put("summary","我要换东西");//付款摘要 | |||
| /** | |||
| @@ -83,6 +93,12 @@ public class AppTest { | |||
| */ | |||
| // String s = HttpUtil.doPost("https://openapitest.malls.iformall.com/api/userInfo/register", headMap, JSON.toJSONString(paramMap)); | |||
| /** | |||
| * 注册并查询用户详细信息 接口 | |||
| */ | |||
| String s = HttpUtil.doPost("https://openapitest.malls.iformall.com/api/userInfo/get", headMap, JSON.toJSONString(paramMap)); | |||
| /** | |||
| * 创建交易信息 接口 | |||
| */ | |||
| @@ -96,7 +112,7 @@ public class AppTest { | |||
| /** | |||
| * 交易退款 接口 | |||
| */ | |||
| String s = HttpUtil.doPost("https://openapitest.malls.iformall.com/api/thirdCircle/pointDeduction", headMap, JSON.toJSONString(paramMap)); | |||
| // String s = HttpUtil.doPost("https://openapitest.malls.iformall.com/api/thirdCircle/pointDeduction", headMap, JSON.toJSONString(paramMap)); | |||
| System.out.println(s); | |||
| @@ -564,6 +564,7 @@ public enum ErrorCode{ | |||
| PICTURE_ANALYZING_ERROR(40002, "您上传的图片无法解析,请检查"), | |||
| PICTURE_SIZE_CUSTOMIZE(40003, "图片超过大小限制"), | |||
| PICTURE_W_H_CUSTOMIZE(40004, "图片不符合宽高限制"), | |||
| PICTURE_ENDWIDTH_ERROR(40005, "格式不正确"), | |||
| /** | |||
| * 电费生成配置 | |||
| @@ -13,6 +13,7 @@ import lombok.ToString; | |||
| import java.math.BigDecimal; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| @TableName(value = "tt_coupon") | |||
| @Data | |||
| @@ -57,8 +58,11 @@ public class TtCoupon extends TenantEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="videoId") | |||
| private String videoId; | |||
| @io.swagger.annotations.ApiModelProperty(value="视频时长(分钟)",name="videoTime") | |||
| private Integer videoTime; | |||
| @io.swagger.annotations.ApiModelProperty(value="视频时长(秒)",name="videoTime") | |||
| private String videoTime; | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="videoUrl") | |||
| private String videoUrl; | |||
| @io.swagger.annotations.ApiModelProperty(value="富文本内容",name="html") | |||
| private String html; | |||
| @@ -74,7 +78,7 @@ public class TtCoupon extends TenantEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value="原价",name="origPrice") | |||
| private Integer origPrice; | |||
| @io.swagger.annotations.ApiModelProperty(value="是否可预览",name="isPreview") | |||
| @io.swagger.annotations.ApiModelProperty(value="是否可预览",name="isPreview")//弃用 | |||
| private Integer isPreview; | |||
| @io.swagger.annotations.ApiModelProperty(value="预览时长",name="previewDuration") | |||
| private Integer previewDuration; | |||
| @@ -116,9 +120,11 @@ public class TtCoupon extends TenantEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value="作者",name="merchantId") | |||
| private Long merchantId; | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="merchantName")//弃用 | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="merchantName") | |||
| private String merchantName; | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="merchantPic")//弃用 | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="merchantPic") | |||
| private String merchantPic; | |||
| @io.swagger.annotations.ApiModelProperty(value="业态",name="businessId") | |||
| @@ -133,9 +139,12 @@ public class TtCoupon extends TenantEntity { | |||
| private TtCoupon couponCoumn; | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value = "审批流参数", name = "columnCoupons") | |||
| private List<TtCoupon> columnCoupons; | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value = "审批流参数", name = "flowParams") | |||
| private Map<String, Object> flowParams; | |||
| public String getSalePriceStr() { | |||
| if(salePrice!=null) { | |||
| @@ -0,0 +1,20 @@ | |||
| package com.iformall.domain.po.tt; | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import lombok.ToString; | |||
| @TableName(value = "tt_user_collect") | |||
| @Data | |||
| @ToString(callSuper = true) | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class TtUserCollect extends TtUserCollectFollow { | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="couponId") | |||
| private Long couponId; | |||
| } | |||
| @@ -0,0 +1,34 @@ | |||
| package com.iformall.domain.po.tt; | |||
| import com.baomidou.mybatisplus.annotation.TableField; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import java.util.Date; | |||
| @Data | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class TtUserCollectFollow extends TenantEntity { | |||
| protected Long id; | |||
| private Long userId; | |||
| @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 = "是否删除1是0否", name = "isDel") | |||
| private Integer isDel; | |||
| @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; | |||
| } | |||
| @@ -0,0 +1,18 @@ | |||
| package com.iformall.domain.po.tt; | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import lombok.ToString; | |||
| @TableName(value = "tt_user_follow") | |||
| @Data | |||
| @ToString(callSuper = true) | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class TtUserFollow extends TtUserCollectFollow { | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="merchernId") | |||
| private Long merchernId; | |||
| } | |||
| @@ -0,0 +1,49 @@ | |||
| package com.iformall.domain.po.tt; | |||
| 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 = "tt_video_library") | |||
| @Data | |||
| @ToString(callSuper = true) | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class TtVideoLibrary extends TenantEntity { | |||
| protected Long id; | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="videoId") | |||
| private String videoId; | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="videoUrl") | |||
| private String videoUrl; | |||
| @io.swagger.annotations.ApiModelProperty(value="封面图",name="preview") | |||
| private String preview; | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="name") | |||
| private String name; | |||
| @io.swagger.annotations.ApiModelProperty(value="时长",name="duration") | |||
| private String duration; | |||
| @io.swagger.annotations.ApiModelProperty(value="有效时间",name="exceedTime") | |||
| private Date exceedTime; | |||
| @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 = "是否删除1是0否", name = "isDel") | |||
| private Integer isDel; | |||
| @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; | |||
| } | |||
| @@ -0,0 +1,35 @@ | |||
| package com.iformall.douyin.miniapp.api; | |||
| import cn.binarywang.wx.miniapp.bean.AbstractWxMaQrcodeWrapper; | |||
| import cn.binarywang.wx.miniapp.util.json.WxMaGsonBuilder; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import java.io.Serializable; | |||
| /** | |||
| * @author <a href="https://github.com/binarywang">Binary Wang</a> | |||
| */ | |||
| @Data | |||
| @EqualsAndHashCode(callSuper = false) | |||
| public class TtMaQrcode extends AbstractWxMaQrcodeWrapper implements Serializable { | |||
| private static final long serialVersionUID = 5777119669111011584L; | |||
| private String appname; | |||
| private String path; | |||
| private int width = 430; | |||
| public TtMaQrcode(String appname, String path, int width) { | |||
| this.appname = appname; | |||
| this.path = path; | |||
| this.width = width; | |||
| } | |||
| public static TtMaQrcode fromJson(String json) { | |||
| return WxMaGsonBuilder.create().fromJson(json, TtMaQrcode.class); | |||
| } | |||
| @Override | |||
| public String toString() { | |||
| return WxMaGsonBuilder.create().toJson(this); | |||
| } | |||
| } | |||
| @@ -0,0 +1,31 @@ | |||
| package com.iformall.douyin.miniapp.api; | |||
| import me.chanjar.weixin.common.error.WxErrorException; | |||
| import java.io.File; | |||
| /** | |||
| * <pre> | |||
| * 二维码相关操作接口. | |||
| * | |||
| * </pre> | |||
| * | |||
| * @author <a href="https://github.com/binarywang">Binary Wang</a> | |||
| */ | |||
| public interface TtMaQrcodeService { | |||
| String GET_TTACODE_URL = "https://developer.toutiao.com/api/apps/qrcode"; | |||
| /** | |||
| * 接口A: 获取小程序码. | |||
| * | |||
| * @param path 不能为空,最大长度 128 字节 | |||
| * @param width 默认430 二维码的宽度 | |||
| * @return 文件对象 | |||
| * @throws WxErrorException 异常 | |||
| */ | |||
| File createTtaCode(String appname, String path, int width) throws WxErrorException; | |||
| } | |||
| @@ -0,0 +1,26 @@ | |||
| package com.iformall.douyin.miniapp.api.impl; | |||
| import cn.binarywang.wx.miniapp.util.QrcodeRequestExecutor; | |||
| import com.iformall.douyin.miniapp.api.TtMaQrcode; | |||
| import com.iformall.douyin.miniapp.api.TtMaQrcodeService; | |||
| import com.iformall.douyin.miniapp.api.TtMaService; | |||
| import lombok.AllArgsConstructor; | |||
| import me.chanjar.weixin.common.error.WxErrorException; | |||
| import java.io.File; | |||
| /** | |||
| * @author <a href="https://github.com/binarywang">Binary Wang</a> | |||
| */ | |||
| @AllArgsConstructor | |||
| public class TtMaQrcodeServiceImpl implements TtMaQrcodeService { | |||
| private TtMaService ttMaService; | |||
| @Override | |||
| public File createTtaCode(String appname, String path, int width) throws WxErrorException { | |||
| final QrcodeRequestExecutor executor = new QrcodeRequestExecutor(this.ttMaService.getRequestHttp()); | |||
| return this.ttMaService.execute(executor, GET_TTACODE_URL, new TtMaQrcode(appname,path, width)); | |||
| } | |||
| } | |||
| @@ -15,7 +15,7 @@ public enum EnumPayWay { | |||
| PAY_WAY_POS_NEU(11, "POS 东软",EnumPayWayType.NEU_POS,null,EnumCardSpendFrom.POS), | |||
| PAY_WAY_NOT_UNPAY_MERCHANT(91, "商户注券,无需支付",null,null,null), | |||
| PAY_WAY_NOT_UNPAY_VERRIFY(92, "核销发券,无需支付",null,null,null), | |||
| PAY_WAY_NOT_UNPAY_B_MA(93, "B端扫码支付发券,无需支付",null,null,null), | |||
| PAY_WAY_NOT_UNPAY_B_MA(93, "支付发券,无需支付",null,null,null), | |||
| PAY_WAY_NOT_UNPAY_CAR_STOP(94, "停车发券,无需支付",null,null,null), | |||
| PAY_WAY_NOT_UNPAY_SYSTEM_SEND(95, "系统定时发放券,无需支付",null,null,null), | |||
| PAY_WAY_NOT_UNPAY_BATCH_SEND(96, "后台批量发券,无需支付",null,null,null), | |||
| @@ -0,0 +1,42 @@ | |||
| package com.iformall.enums; | |||
| /** | |||
| * Created by Stormeye on 2018/08/09. | |||
| */ | |||
| public enum EnumTtOrderStatus { | |||
| ORDER_STATUS_PENDING_PAYMENT(0, "待付款"), | |||
| ORDER_STATUS_PAYMENT_ING(1,"支付中"), | |||
| ORDER_STATUS_PAYMENT_SUCCESS(1, "已支付"), | |||
| ORDER_STATUS_OVERTIME_CANCEL(2, "已取消"), | |||
| ORDER_STATUS_PENDING_REFUND(3, "待退款"), | |||
| ORDER_STATUS_REFUND_SUCCESS(4,"已退款"), | |||
| ORDER_STATUS_REFUND_FAILD(5, "退款失败"), | |||
| ; | |||
| public static EnumTtOrderStatus getEnum(Integer code) { | |||
| for (EnumTtOrderStatus value : values()) { | |||
| if (value.getCode().equals(code)) { | |||
| return value; | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| private Integer code; | |||
| private String message; | |||
| EnumTtOrderStatus(Integer code, String message) { | |||
| this.code = code; | |||
| this.message = message; | |||
| } | |||
| public Integer getCode() { | |||
| return code; | |||
| } | |||
| public String getMessage() { | |||
| return message; | |||
| } | |||
| } | |||
| @@ -0,0 +1,14 @@ | |||
| package com.iformall.mapper; | |||
| import com.iformall.common.CommonMapper; | |||
| import com.iformall.domain.po.tt.TtUserCollect; | |||
| import java.util.List; | |||
| public interface TtUserCollectMapper extends CommonMapper<TtUserCollect, Long> { | |||
| List<TtUserCollect> findList(TtUserCollect collect); | |||
| int deleteById(Long id); | |||
| } | |||
| @@ -0,0 +1,14 @@ | |||
| package com.iformall.mapper; | |||
| import com.iformall.common.CommonMapper; | |||
| import com.iformall.domain.po.tt.TtUserFollow; | |||
| import java.util.List; | |||
| public interface TtUserFollowMapper extends CommonMapper<TtUserFollow, Long> { | |||
| List<TtUserFollow> findList(TtUserFollow collect); | |||
| int deleteById(Long id); | |||
| } | |||
| @@ -0,0 +1,15 @@ | |||
| package com.iformall.mapper; | |||
| import com.iformall.common.CommonMapper; | |||
| import com.iformall.domain.po.tt.TtVideoLibrary; | |||
| import java.util.List; | |||
| public interface TtVideoLibraryMapper extends CommonMapper<TtVideoLibrary, Long> { | |||
| List<TtVideoLibrary> findList(TtVideoLibrary video); | |||
| int deleteById(Long id); | |||
| TtVideoLibrary getByVideoId(String videoId); | |||
| } | |||
| @@ -7,7 +7,7 @@ import org.springframework.scheduling.annotation.Async; | |||
| public interface WxCallBackService { | |||
| /** | |||
| * 积分同步 | |||
| * | |||
| * @param record | |||
| */ | |||
| @Async | |||
| @@ -252,20 +252,35 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { | |||
| return false; | |||
| } else if (wxCouponSend.getSendType().equals(EnumCouponSendSendType.B_MICROPAY.getCode())) { | |||
| if (param.getClass().equals(WxOrder.class)){ | |||
| WxOrder wxOrder = (WxOrder) param; | |||
| WxOrder wxOrder = (WxOrder) param; | |||
| try { | |||
| JSONObject jo = JSONObject.parseObject(wxCouponSend.getConditions()); | |||
| WxMerchantBUser wxMerchantBUser = wxMerchantBUserMapper.selectById(wxOrder.getProductId()); | |||
| try { | |||
| JSONObject jo = JSONObject.parseObject(wxCouponSend.getConditions()); | |||
| WxMerchantBUser wxMerchantBUser = wxMerchantBUserMapper.selectById(wxOrder.getProductId()); | |||
| if (wxMerchantBUser.getMerchantId() != null | |||
| && wxMerchantBUser.getMerchantId().equals(jo.getLong("id"))) { | |||
| return true; | |||
| } | |||
| } catch (Exception e) { | |||
| logger.error("收银发券条件判断错误:ID=" + wxCouponSend.getId() + e.getMessage()); | |||
| } | |||
| }else if(param.getClass().equals(WxThirdPartyOrders.class)){ | |||
| WxThirdPartyOrders thirdOrder = (WxThirdPartyOrders) param; | |||
| if (wxMerchantBUser.getMerchantId() != null | |||
| && wxMerchantBUser.getMerchantId().equals(jo.getLong("id"))) { | |||
| return true; | |||
| try { | |||
| JSONObject jo = JSONObject.parseObject(wxCouponSend.getConditions()); | |||
| if (thirdOrder.getMerchantId() != null | |||
| && thirdOrder.getMerchantId().equals(jo.getLong("id"))) { | |||
| return true; | |||
| } | |||
| } catch (Exception e) { | |||
| logger.error("收银发券条件判断错误:ID=" + wxCouponSend.getId() + e.getMessage()); | |||
| } | |||
| } catch (Exception e) { | |||
| logger.error("收银发券条件判断错误:ID=" + wxCouponSend.getId() + e.getMessage()); | |||
| } | |||
| return false; | |||
| } else if (wxCouponSend.getSendType().equals(EnumCouponSendSendType.COUPON_VERIFY.getCode())) { | |||
| @@ -305,12 +320,19 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { | |||
| case COUPON_VERIFY: | |||
| case B_MICROPAY: | |||
| case C_ORDER: | |||
| if (!param.getClass().equals(WxOrder.class)) | |||
| if (param.getClass().equals(WxOrder.class)){ | |||
| WxOrder order = (WxOrder) param; | |||
| cUserId = order.getCUserId(); | |||
| tenantEntity = order; | |||
| break; | |||
| }else if(param.getClass().equals(WxThirdPartyOrders.class)){ | |||
| WxThirdPartyOrders thirdOrder = (WxThirdPartyOrders) param; | |||
| cUserId = thirdOrder.getCUserId(); | |||
| tenantEntity = thirdOrder; | |||
| break; | |||
| }else{ | |||
| return false; | |||
| WxOrder order = (WxOrder) param; | |||
| cUserId = order.getCUserId(); | |||
| tenantEntity = order; | |||
| break; | |||
| } | |||
| default: | |||
| return false; | |||
| } | |||
| @@ -47,6 +47,8 @@ public class WxThirdPartyOrdersServiceImpl implements WxThirdPartyOrdersService | |||
| @Autowired | |||
| WxCreditHistoryService wxCreditHistoryService; | |||
| @Autowired | |||
| WxCouponSendService wxCouponSendService; | |||
| @Override | |||
| @@ -171,7 +173,15 @@ public class WxThirdPartyOrdersServiceImpl implements WxThirdPartyOrdersService | |||
| record.setIncreasedPoints(creditNum); | |||
| record.setPointsUpdateTime(creditHistory.getCreateDate()); | |||
| this.updatePoints(record); | |||
| try { | |||
| wxCouponSendService.sendCouponToUser(EnumCouponSendSendType.B_MICROPAY, record,EnumPayWay.PAY_WAY_NOT_UNPAY_B_MA); | |||
| } catch (Exception e) { | |||
| logger.error("B端刷卡支付发券: " + e.getMessage()); | |||
| } | |||
| } | |||
| redisLock.unlock(lockKey, timeStr); | |||
| }else { | |||
| logger.debug("CacheAspect 读库等待中, key:{}: " + lockKey); | |||
| @@ -2,7 +2,9 @@ package com.iformall.service.tt; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.po.tt.TtCoupon; | |||
| import org.springframework.scheduling.annotation.Async; | |||
| public interface TtCouponService { | |||
| @@ -39,4 +41,11 @@ public interface TtCouponService { | |||
| void deleteById(Long id); | |||
| TtCoupon detail(Long productId); | |||
| ResultData puton(Long id); | |||
| ResultData putoff(Long id); | |||
| @Async | |||
| void collectCoupon(TenantEntity tenantEntity,Long memberId, Long id); | |||
| } | |||
| @@ -3,6 +3,7 @@ package com.iformall.service.tt; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.dto.OrderSaveDto; | |||
| import com.iformall.domain.po.WxAppinfo; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.po.tt.TtOrder; | |||
| import com.iformall.enums.EnumPayWay; | |||
| @@ -24,4 +25,8 @@ public interface TtOrderService { | |||
| ResultData cancelOrder(Long orderId, Long memberId); | |||
| TtOrder detail(Long orderId, Long memberId); | |||
| ResultData createPay(TenantEntity tenantEntity,Long orderId, Long memberId, WxAppinfo appinfo); | |||
| ResultData updateOrderStatus(TenantEntity tenantInfo, Long orderId, Long memberId, WxAppinfo cAppInfo); | |||
| } | |||
| @@ -0,0 +1,23 @@ | |||
| package com.iformall.service.tt; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.po.tt.TtVideoLibrary; | |||
| import org.springframework.scheduling.annotation.Async; | |||
| public interface TtVideoLibraryService { | |||
| /** | |||
| * 根据实体查询分页列表 | |||
| * | |||
| * @param record | |||
| * @param pageIndex | |||
| * @param pageSize | |||
| * @return | |||
| */ | |||
| PageInfo<TtVideoLibrary> listAsPage(TtVideoLibrary record, Integer pageIndex, Integer pageSize); | |||
| @Async | |||
| void saveOrUpdate(TtVideoLibrary video); | |||
| } | |||
| @@ -1,11 +1,19 @@ | |||
| package com.iformall.service.tt.impl; | |||
| import com.alibaba.fastjson.JSONArray; | |||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
| 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.WxMerchant; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.po.tt.TtCoupon; | |||
| import com.iformall.domain.po.tt.TtUserCollect; | |||
| import com.iformall.enums.EnumTtCouponStatus; | |||
| import com.iformall.enums.EnumTtCouponType; | |||
| import com.iformall.enums.EnumYesOrNo; | |||
| import com.iformall.mapper.*; | |||
| import com.iformall.service.WxMerchantService; | |||
| import com.iformall.service.tt.TtCouponService; | |||
| @@ -14,6 +22,8 @@ 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.math.BigDecimal; | |||
| import java.util.*; | |||
| @@ -30,6 +40,9 @@ public class TtCouponServiceImpl implements TtCouponService { | |||
| @Autowired | |||
| WxMerchantService wxMerchantService; | |||
| @Autowired | |||
| TtUserCollectMapper ttUserCollectMapper; | |||
| @Override | |||
| public PageInfo<TtCoupon> listAsPage(TtCoupon record, Integer pageIndex, Integer pageSize) { | |||
| @@ -43,6 +56,7 @@ public class TtCouponServiceImpl implements TtCouponService { | |||
| @Override | |||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||
| public ResultData saveOrUpdate(TtCoupon record) { | |||
| if (StringUtils.isNotEmpty(record.getSalePriceStr())) { | |||
| @@ -51,6 +65,13 @@ public class TtCouponServiceImpl implements TtCouponService { | |||
| if (StringUtils.isNotEmpty(record.getOrigPriceStr())) { | |||
| record.setOrigPrice(new BigDecimal(record.getOrigPriceStr()).multiply(new BigDecimal(100)).intValue()); | |||
| } | |||
| if(record.getSalePrice() == null || record.getSalePrice().intValue() == 0){ | |||
| record.setSalePrice(0); | |||
| record.setIsPayment(EnumYesOrNo.NO.getCode()); | |||
| record.setPreviewDuration(0); | |||
| }else{ | |||
| record.setIsPayment(EnumYesOrNo.YES.getCode()); | |||
| } | |||
| if (StringUtils.isBlank(record.getCoverPicture())) { | |||
| List<String> strList = new ArrayList<String>(); | |||
| @@ -62,6 +83,12 @@ public class TtCouponServiceImpl implements TtCouponService { | |||
| } | |||
| } | |||
| if(record.getStatus() == null){ | |||
| record.setStatus(EnumTtCouponStatus.TTCOUPON_STATUS_DRAFT.getCode()); | |||
| } | |||
| if(!record.getStatus().equals(EnumTtCouponStatus.TTCOUPON_STATUS_DRAFT.getCode())){ | |||
| record.setStatus(EnumTtCouponStatus.TTCOUPON_STATUS_EXAMINE.getCode()); | |||
| } | |||
| if (record.getId() == null) { | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| @@ -74,7 +101,21 @@ public class TtCouponServiceImpl implements TtCouponService { | |||
| record.setUpdateDate(new Date()); | |||
| ttCouponMapper.updateById(record); | |||
| } | |||
| return new ResultData(record.getId()); | |||
| if(record.getType().equals(EnumTtCouponType.COUPON_COLUMN.getCode()) | |||
| && record.getColumnCoupons() != null && record.getColumnCoupons().size() > 0){ | |||
| TtCoupon couponD = new TtCoupon(); | |||
| couponD.setColumnId(record.getId()); | |||
| couponD.setType(EnumTtCouponType.COUPON_MORE.getCode()); | |||
| ttCouponMapper.delete(new QueryWrapper<TtCoupon>(couponD)); | |||
| for (TtCoupon ttc:record.getColumnCoupons()) { | |||
| ttc.updateTenantInfo(record); | |||
| ttc.setType(EnumTtCouponType.COUPON_MORE.getCode()); | |||
| ttc.setColumnId(record.getId()); | |||
| this.saveOrUpdate(ttc); | |||
| } | |||
| } | |||
| return new ResultData(); | |||
| } | |||
| @Override | |||
| @@ -85,7 +126,67 @@ public class TtCouponServiceImpl implements TtCouponService { | |||
| @Override | |||
| public TtCoupon detail(Long productId) { | |||
| TtCoupon byId = this.getById(productId); | |||
| byId.setAuthor(wxMerchantService.getById(byId.getMerchantId())); | |||
| if(byId == null){ | |||
| return byId; | |||
| } | |||
| // WxMerchant author = wxMerchantService.getById(byId.getMerchantId()); | |||
| // byId.setMerchantName(author.getName()); | |||
| // byId.setMerchantPic(author.getImgUrl()); | |||
| // byId.setAuthor(wxMerchantService.getById(byId.getMerchantId())); | |||
| if(byId.getType().equals(EnumTtCouponType.COUPON_COLUMN.getCode())){ | |||
| TtCoupon couponQ = new TtCoupon(); | |||
| couponQ.setColumnId(productId); | |||
| couponQ.setType(EnumTtCouponType.COUPON_MORE.getCode()); | |||
| byId.setColumnCoupons(ttCouponMapper.findList(couponQ)); | |||
| } | |||
| return byId; | |||
| } | |||
| @Override | |||
| public ResultData puton(Long id) { | |||
| TtCoupon byId = this.getById(id); | |||
| if(byId == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"未找到课程"); | |||
| } | |||
| if(!byId.getStatus().equals(EnumTtCouponStatus.TTCOUPON_STATUS_BEFOR_SHELF.getCode()) | |||
| && !byId.getStatus().equals(EnumTtCouponStatus.TTCOUPON_STATUS_AFTER_SHELF.getCode())){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"此课程状态不允许上架或者已上架"); | |||
| } | |||
| byId.setStatus(EnumTtCouponStatus.TTCOUPON_STATUS_SHELFING.getCode()); | |||
| byId.setUpdateDate(new Date()); | |||
| ttCouponMapper.updateById(byId); | |||
| return new ResultData(); | |||
| } | |||
| @Override | |||
| public ResultData putoff(Long id) { | |||
| TtCoupon byId = this.getById(id); | |||
| if(byId == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"未找到课程"); | |||
| } | |||
| if(!byId.getStatus().equals(EnumTtCouponStatus.TTCOUPON_STATUS_SHELFING.getCode())){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"此课程状态不允许下架或者已下架"); | |||
| } | |||
| byId.setStatus(EnumTtCouponStatus.TTCOUPON_STATUS_AFTER_SHELF.getCode()); | |||
| byId.setUpdateDate(new Date()); | |||
| ttCouponMapper.updateById(byId); | |||
| return new ResultData(); | |||
| } | |||
| @Override | |||
| public void collectCoupon(TenantEntity tenantEntity,Long memberId, Long id) { | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| TtUserCollect userCollect = new TtUserCollect(); | |||
| userCollect.setId(idWorker.nextId()); | |||
| userCollect.updateTenantInfo(tenantEntity); | |||
| userCollect.setUserId(memberId); | |||
| userCollect.setCouponId(id); | |||
| userCollect.setCreateDate(new Date()); | |||
| userCollect.setUpdateDate(new Date()); | |||
| try { | |||
| ttUserCollectMapper.insert(userCollect); | |||
| } catch (Exception e) { | |||
| // e.printStackTrace(); | |||
| } | |||
| } | |||
| } | |||
| @@ -9,9 +9,14 @@ import com.iformall.domain.po.*; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.po.tt.TtCoupon; | |||
| import com.iformall.domain.po.tt.TtOrder; | |||
| import com.iformall.douyin.pay.DouYinPayHelper; | |||
| import com.iformall.douyin.pay.orderQuery.OrderQueryResult; | |||
| import com.iformall.douyin.pay.preOrder.CreatePreOrderResult; | |||
| import com.iformall.douyin.pay.preOrder.DouYinCreatePreOrder; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.mapper.*; | |||
| import com.iformall.service.WxAppinfoService; | |||
| import com.iformall.service.WxCUserBasicInfoService; | |||
| import com.iformall.service.tt.TtCouponService; | |||
| import com.iformall.service.tt.TtOrderService; | |||
| @@ -28,6 +33,8 @@ public class TtOrderServiceImpl implements TtOrderService { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| private final Integer time_out = 30*60; | |||
| @Autowired | |||
| private TtOrderMapper ttOrderMapper; | |||
| @@ -37,6 +44,9 @@ public class TtOrderServiceImpl implements TtOrderService { | |||
| @Autowired | |||
| private WxCUserBasicInfoService wxCUserBasicInfoService; | |||
| @Autowired | |||
| private WxAppinfoService wxAppinfoService; | |||
| @Override | |||
| public PageInfo<TtOrder> listAsPage(TtOrder record, Integer pageIndex, Integer pageSize) { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> ttOrderMapper.findList(record)); | |||
| @@ -53,8 +63,8 @@ public class TtOrderServiceImpl implements TtOrderService { | |||
| orderQ.setCUserId(cUserId); | |||
| orderQ.setProductId(couponId); | |||
| List<Integer> statuss = new ArrayList<>(); | |||
| statuss.add(EnumOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode()); | |||
| statuss.add(EnumOrderStatus.ORDER_STATUS_PAYMENT_SUCCESS.getCode()); | |||
| statuss.add(EnumTtOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode()); | |||
| statuss.add(EnumTtOrderStatus.ORDER_STATUS_PAYMENT_SUCCESS.getCode()); | |||
| orderQ.setStatusS(statuss); | |||
| Integer listCount = ttOrderMapper.findListCount(orderQ); | |||
| if(listCount.intValue() > 0){ | |||
| @@ -72,6 +82,9 @@ public class TtOrderServiceImpl implements TtOrderService { | |||
| if (!coupon.getStatus().equals(EnumTtCouponStatus.TTCOUPON_STATUS_SHELFING.getCode())) { | |||
| return new ResultData(ErrorCode.TTCOUPON_IS_TAKE_OFF); | |||
| } | |||
| if(coupon.getSalePrice() == null || coupon.getSalePrice().intValue() == 0){ | |||
| return new ResultData(ErrorCode.TTCOUPON_IS_TAKE_OFF); | |||
| } | |||
| try { | |||
| // 4.2 保存订单 | |||
| @@ -86,10 +99,10 @@ public class TtOrderServiceImpl implements TtOrderService { | |||
| order.setPaymentType(EnumPayType.PAY_PAYMENT.getCode()); | |||
| order.setPayment(coupon.getSalePrice()); | |||
| if(order.getPayment() == null || order.getPayment().intValue() == 0){ | |||
| order.setOrderStatus(EnumOrderStatus.ORDER_STATUS_PAYMENT_SUCCESS.getCode()); | |||
| order.setOrderStatus(EnumTtOrderStatus.ORDER_STATUS_PAYMENT_SUCCESS.getCode()); | |||
| order.setPaymentTime(now); | |||
| }else{ | |||
| order.setOrderStatus(EnumOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode()); | |||
| order.setOrderStatus(EnumTtOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode()); | |||
| } | |||
| order.setCreateDate(now); | |||
| order.setUpdateDate(now); | |||
| @@ -113,27 +126,27 @@ public class TtOrderServiceImpl implements TtOrderService { | |||
| if(memberId != null && !ttOrder.getCUserId().equals(memberId)){ | |||
| return new ResultData(ErrorCode.ORDER_USER_NOT_MATCH); | |||
| } | |||
| if(ttOrder.getOrderStatus().equals(EnumOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode())){//订单待付款 | |||
| if(ttOrder.getOrderStatus().equals(EnumTtOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode())){//订单待付款 | |||
| TtOrder record = new TtOrder(); | |||
| record.setId(ttOrder.getId()); | |||
| record.setOrderStatus(EnumOrderStatus.ORDER_STATUS_OVERTIME_CANCEL.getCode()); | |||
| record.setOrderStatus(EnumTtOrderStatus.ORDER_STATUS_OVERTIME_CANCEL.getCode()); | |||
| record.setUpdateDate(new Date()); | |||
| ttOrderMapper.updateById(record); | |||
| return new ResultData(); | |||
| }else | |||
| if(ttOrder.getOrderStatus().equals(EnumOrderStatus.ORDER_STATUS_PAYMENT_SUCCESS.getCode())){//订单已支付 | |||
| if(ttOrder.getOrderStatus().equals(EnumTtOrderStatus.ORDER_STATUS_PAYMENT_SUCCESS.getCode())){//订单已支付 | |||
| return new ResultData(ErrorCode.ORDER_HAD_PAY); | |||
| }else | |||
| if(ttOrder.getOrderStatus().equals(EnumOrderStatus.ORDER_STATUS_OVERTIME_CANCEL.getCode())){//订单已取消 | |||
| if(ttOrder.getOrderStatus().equals(EnumTtOrderStatus.ORDER_STATUS_OVERTIME_CANCEL.getCode())){//订单已取消 | |||
| return new ResultData(ErrorCode.ORDER_HAD_CANCEL); | |||
| }else | |||
| if(ttOrder.getOrderStatus().equals(EnumOrderStatus.ORDER_STATUS_PENDING_REFUND.getCode())){//订单待退款 | |||
| if(ttOrder.getOrderStatus().equals(EnumTtOrderStatus.ORDER_STATUS_PENDING_REFUND.getCode())){//订单待退款 | |||
| return new ResultData(ErrorCode.ORDER_PAY_IN_REFUND); | |||
| }else | |||
| if(ttOrder.getOrderStatus().equals(EnumOrderStatus.ORDER_STATUS_REFUND_SUCCESS.getCode())){//订单已退款 | |||
| if(ttOrder.getOrderStatus().equals(EnumTtOrderStatus.ORDER_STATUS_REFUND_SUCCESS.getCode())){//订单已退款 | |||
| return new ResultData(ErrorCode.ORDER_PAY_REFUND); | |||
| }else | |||
| if(ttOrder.getOrderStatus().equals(EnumOrderStatus.ORDER_STATUS_REFUND_FAILD.getCode())){//订单退款失败 | |||
| if(ttOrder.getOrderStatus().equals(EnumTtOrderStatus.ORDER_STATUS_REFUND_FAILD.getCode())){//订单退款失败 | |||
| return new ResultData(ErrorCode.ORDER_PAY_REFUND_FAIL); | |||
| } | |||
| return new ResultData(ErrorCode.ORDER_IS_FAIL); | |||
| @@ -153,4 +166,138 @@ public class TtOrderServiceImpl implements TtOrderService { | |||
| return ttOrder; | |||
| } | |||
| @Override | |||
| public ResultData createPay(TenantEntity tenantEntity,Long orderId, Long memberId, WxAppinfo appInfo) { | |||
| TtOrder order = ttOrderMapper.selectById(orderId); | |||
| if (null == order) { | |||
| logger.error("pay order, order not allow, orderId: " + orderId); | |||
| return new ResultData(ErrorCode.ORDER_IS_NOT_FIND); | |||
| } | |||
| if(!order.getCUserId().equals(memberId)){ | |||
| return new ResultData(ErrorCode.ORDER_USER_NOT_MATCH); | |||
| } | |||
| WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoService.getById(memberId,tenantEntity.getFinalTenantId()); | |||
| if ( null == wxCUserBasicInfo) { | |||
| logger.error("会员用户不存在."+memberId); | |||
| return new ResultData(ErrorCode.USER_IS_EMPTY.getCode(),"会员用户不存在."+memberId); | |||
| } | |||
| if (null != wxCUserBasicInfo && EnumCreditLockedStatus.CLOSE.getCode().equals(wxCUserBasicInfo.getStatus())) { | |||
| return new ResultData(ErrorCode.MEMBER_IS_LOCKED); | |||
| } | |||
| // WxAppinfo appInfo = wxAppinfoService.getByAppId(appId); | |||
| if(appInfo == null) { | |||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | |||
| } | |||
| TtCoupon coupon = ttCouponService.getById(order.getProductId()); | |||
| if (!coupon.getStatus().equals(EnumTtCouponStatus.TTCOUPON_STATUS_SHELFING.getCode())) { | |||
| logger.error("券已经下架了>>>" + order.getProductId()); | |||
| return new ResultData(ErrorCode.COUPON_CHANNEL_IS_TAKE_OFF); | |||
| } | |||
| if (order.getPaymentType() != EnumPayType.PAY_PAYMENT.getCode()) { | |||
| return new ResultData(ErrorCode.PAY_ORDER_IS_NOT_PAYMENT); | |||
| } | |||
| if (order.getOrderStatus() == EnumTtOrderStatus.ORDER_STATUS_PAYMENT_SUCCESS.getCode()) { | |||
| logger.error("订单已支付: " + order.toString()); | |||
| return new ResultData(ErrorCode.ORDER_HAD_PAY); | |||
| } else if (order.getOrderStatus() == EnumTtOrderStatus.ORDER_STATUS_OVERTIME_CANCEL.getCode()) { | |||
| logger.error("订单已取消: " + order.toString()); | |||
| return new ResultData(ErrorCode.ORDER_HAD_CANCEL); | |||
| } else if(order.getOrderStatus() == EnumTtOrderStatus.ORDER_STATUS_PAYMENT_ING.getCode()){ | |||
| logger.info("订单支付中: " + order.toString()); | |||
| OrderQueryResult orderQueryResult = DouYinPayHelper.orderQuery(appInfo.getAppId(), appInfo.getSecret(), order.getId().toString(), null); | |||
| String trade_state = orderQueryResult.getOrderStatus(); | |||
| if ("PROCESSING".equals(trade_state)) {//处理中 | |||
| return new ResultData(ErrorCode.PAY_ORDER_PAYING); | |||
| }else if ("SUCCESS".equals(trade_state)) {//成功 | |||
| TtOrder orderSuc = new TtOrder(); | |||
| orderSuc.setId(order.getId()); | |||
| orderSuc.setOrderStatus(EnumTtOrderStatus.ORDER_STATUS_PAYMENT_SUCCESS.getCode()); | |||
| orderSuc.setUpdateDate(new Date()); | |||
| ttOrderMapper.updateById(orderSuc); | |||
| return new ResultData(ErrorCode.PAY_ORDER_EXIST,"该订单已经支付,请勿重复支付!"); | |||
| }else if ("FAIL".equals(trade_state)) {//失败 | |||
| }else if ("TIMEOUT".equals(trade_state)) {//超时 | |||
| } | |||
| } else{ | |||
| if (order.getOrderStatus() != EnumTtOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode()) { | |||
| logger.error("订单已支付: " + order.toString()); | |||
| return new ResultData(ErrorCode.ORDER_IS_NOT_PAY); | |||
| } | |||
| } | |||
| DouYinCreatePreOrder preOrder = new DouYinCreatePreOrder(); | |||
| preOrder.setAppId(appInfo.getAppId()); | |||
| preOrder.setOutOrderNo(order.getId().toString()); | |||
| preOrder.setTotalAmount(order.getPayment()); | |||
| preOrder.setSubject(coupon.getTitle()); | |||
| preOrder.setBody(coupon.getTitle()); | |||
| preOrder.setValidTime(time_out); | |||
| // preOrder.setNotifyUrl();//回调地址 | |||
| CreatePreOrderResult preOrderResult = DouYinPayHelper.createPreOrder(preOrder); | |||
| if(preOrderResult.isSuccess()){ | |||
| TtOrder orderSuc = new TtOrder(); | |||
| orderSuc.setId(order.getId()); | |||
| orderSuc.setOrderStatus(EnumTtOrderStatus.ORDER_STATUS_PAYMENT_ING.getCode()); | |||
| orderSuc.setUpdateDate(new Date()); | |||
| ttOrderMapper.updateById(orderSuc); | |||
| } | |||
| return new ResultData(preOrderResult); | |||
| } | |||
| @Override | |||
| public ResultData updateOrderStatus(TenantEntity tenantEntity, Long orderId, Long memberId, WxAppinfo appInfo) { | |||
| TtOrder order = ttOrderMapper.selectById(orderId); | |||
| if (null == order) { | |||
| logger.error("pay order, order not allow, orderId: " + orderId); | |||
| return new ResultData(ErrorCode.ORDER_IS_NOT_FIND); | |||
| } | |||
| if(!order.getCUserId().equals(memberId)){ | |||
| return new ResultData(ErrorCode.ORDER_USER_NOT_MATCH); | |||
| } | |||
| WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoService.getById(memberId,tenantEntity.getFinalTenantId()); | |||
| if ( null == wxCUserBasicInfo) { | |||
| logger.error("会员用户不存在."+memberId); | |||
| return new ResultData(ErrorCode.USER_IS_EMPTY.getCode(),"会员用户不存在."+memberId); | |||
| } | |||
| if (null != wxCUserBasicInfo && EnumCreditLockedStatus.CLOSE.getCode().equals(wxCUserBasicInfo.getStatus())) { | |||
| return new ResultData(ErrorCode.MEMBER_IS_LOCKED); | |||
| } | |||
| // WxAppinfo appInfo = wxAppinfoService.getByAppId(appId); | |||
| if(appInfo == null) { | |||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | |||
| } | |||
| if(order.getOrderStatus() == EnumTtOrderStatus.ORDER_STATUS_PAYMENT_ING.getCode()){ | |||
| logger.info("订单支付中: " + order.toString()); | |||
| OrderQueryResult orderQueryResult = DouYinPayHelper.orderQuery(appInfo.getAppId(), appInfo.getSecret(), order.getId().toString(), null); | |||
| String trade_state = orderQueryResult.getOrderStatus(); | |||
| if ("PROCESSING".equals(trade_state)) {//处理中 | |||
| return new ResultData(ErrorCode.PAY_ORDER_PAYING); | |||
| }else if ("SUCCESS".equals(trade_state)) {//成功 | |||
| TtOrder orderSuc = new TtOrder(); | |||
| orderSuc.setId(order.getId()); | |||
| orderSuc.setOrderStatus(EnumTtOrderStatus.ORDER_STATUS_PAYMENT_SUCCESS.getCode()); | |||
| orderSuc.setUpdateDate(new Date()); | |||
| ttOrderMapper.updateById(orderSuc); | |||
| return new ResultData(ErrorCode.PAY_ORDER_EXIST,"该订单已经支付,请勿重复支付!"); | |||
| }else if ("FAIL".equals(trade_state)) {//失败 | |||
| TtOrder orderSuc = new TtOrder(); | |||
| orderSuc.setId(order.getId()); | |||
| orderSuc.setOrderStatus(EnumTtOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode()); | |||
| orderSuc.setUpdateDate(new Date()); | |||
| ttOrderMapper.updateById(orderSuc); | |||
| }else if ("TIMEOUT".equals(trade_state)) {//超时 | |||
| TtOrder orderSuc = new TtOrder(); | |||
| orderSuc.setId(order.getId()); | |||
| orderSuc.setOrderStatus(EnumTtOrderStatus.ORDER_STATUS_OVERTIME_CANCEL.getCode()); | |||
| orderSuc.setUpdateDate(new Date()); | |||
| ttOrderMapper.updateById(orderSuc); | |||
| } | |||
| } | |||
| return new ResultData(); | |||
| } | |||
| } | |||
| @@ -0,0 +1,67 @@ | |||
| package com.iformall.service.tt.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.WxAppinfo; | |||
| import com.iformall.domain.po.WxCUserBasicInfo; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.po.tt.TtCoupon; | |||
| import com.iformall.domain.po.tt.TtOrder; | |||
| import com.iformall.domain.po.tt.TtVideoLibrary; | |||
| import com.iformall.douyin.pay.DouYinPayHelper; | |||
| import com.iformall.douyin.pay.orderQuery.OrderQueryResult; | |||
| import com.iformall.douyin.pay.preOrder.CreatePreOrderResult; | |||
| import com.iformall.douyin.pay.preOrder.DouYinCreatePreOrder; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.mapper.TtOrderMapper; | |||
| import com.iformall.mapper.TtVideoLibraryMapper; | |||
| import com.iformall.service.WxAppinfoService; | |||
| import com.iformall.service.WxCUserBasicInfoService; | |||
| import com.iformall.service.tt.TtCouponService; | |||
| import com.iformall.service.tt.TtOrderService; | |||
| import com.iformall.service.tt.TtVideoLibraryService; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import java.util.ArrayList; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| @Service | |||
| public class TtVideoLibraryServiceImpl implements TtVideoLibraryService { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private TtVideoLibraryMapper ttVideoLibraryMapper; | |||
| @Override | |||
| public PageInfo<TtVideoLibrary> listAsPage(TtVideoLibrary record, Integer pageIndex, Integer pageSize) { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> ttVideoLibraryMapper.findList(record)); | |||
| } | |||
| @Override | |||
| public void saveOrUpdate(TtVideoLibrary video) { | |||
| TtVideoLibrary videoLib = ttVideoLibraryMapper.getByVideoId(video.getVideoId()); | |||
| if(videoLib != null && videoLib.getIsDel().equals(EnumYesOrNo.YES.getCode())){ | |||
| videoLib.setIsDel(EnumYesOrNo.NO.getCode()); | |||
| videoLib.setUpdateDate(new Date()); | |||
| ttVideoLibraryMapper.updateById(videoLib); | |||
| } | |||
| if(videoLib == null){ | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| video.setId(idWorker.nextId()); | |||
| video.setCreateDate(new Date()); | |||
| video.setUpdateDate(new Date()); | |||
| ttVideoLibraryMapper.insert(video); | |||
| } | |||
| } | |||
| } | |||
| @@ -12,7 +12,9 @@ | |||
| <result column="title" jdbcType="VARCHAR" property="title"/> | |||
| <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/> | |||
| <result column="video_id" jdbcType="VARCHAR" property="videoId"/> | |||
| <result column="video_time" jdbcType="INTEGER" property="videoTime"/> | |||
| <result column="video_time" jdbcType="VARCHAR" property="videoTime"/> | |||
| <result column="video_url" jdbcType="VARCHAR" property="videoUrl"/> | |||
| <result column="html" jdbcType="VARCHAR" property="html"/> | |||
| <result column="is_landscape" jdbcType="INTEGER" property="isLandscape"/> | |||
| <result column="is_payment" jdbcType="INTEGER" property="isPayment"/> | |||
| @@ -36,93 +38,101 @@ | |||
| <result column="column_id" jdbcType="BIGINT" property="columnId"/> | |||
| <result column="popularity" jdbcType="INTEGER" property="popularity"/> | |||
| <result column="merchant_id" jdbcType="BIGINT" property="merchantId"/> | |||
| <result column="merchant_name" jdbcType="VARCHAR" property="merchantName"/> | |||
| <result column="merchant_pic" jdbcType="VARCHAR" property="merchantPic"/> | |||
| <result column="business_id" jdbcType="BIGINT" property="businessId"/> | |||
| <result column="business_name" jdbcType="VARCHAR" property="businessName"/> | |||
| <result column="merchant_name" jdbcType="VARCHAR" property="merchantName"/> | |||
| <result column="merchant_pic" jdbcType="VARCHAR" property="merchantPic"/> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`, `tenant_id`, `parent_tenant_id`, `type`, `cover_img`, `cover_picture`, `detail_picture`, | |||
| `title`, `sub_title`, `video_id`, `video_time`, `html`, `is_landscape`, `is_payment`, | |||
| `sale_price`, `orig_price`, `is_preview`, `preview_duration`, `detail`, `false_sell_count`, | |||
| `dy_title`, `inventory`, `remark`, `status`, `create_date`, `update_date`, | |||
| `see_count`, `sell_count`, `assess_count`, `collect_count`, `is_del`, | |||
| `column_id`, `popularity`, `merchant_id`, `merchant_name`,`merchant_pic`, `business_id`, `business_name` | |||
| c.`id`, c.`tenant_id`, c.`parent_tenant_id`, c.`type`, c.`cover_img`, c.`cover_picture`, c.`detail_picture`, | |||
| c.`title`, c.`sub_title`, c.`video_id`, c.`video_time`,c.`video_url`, c.`html`, c.`is_landscape`, c.`is_payment`, | |||
| c.`sale_price`, c.`orig_price`, c.`is_preview`, c.`preview_duration`, c.`detail`, c.`false_sell_count`, | |||
| c.`dy_title`, c.`inventory`, c.`remark`, c.`status`, c.`create_date`, c.`update_date`, | |||
| c.`see_count`, c.`sell_count`, c.`assess_count`, c.`collect_count`, c.`is_del`, | |||
| c.`column_id`, c.`popularity`, c.`merchant_id`, c.`business_id`, c.`business_name`, | |||
| m.name merchant_name, m.img_url merchant_pic | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| where `is_del` = 0 | |||
| where c.`is_del` = 0 and c.`type` != 3 | |||
| <if test=" null != id "> | |||
| and `id` = #{id} | |||
| and c.`id` = #{id} | |||
| </if> | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| and c.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| and c.`parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test=" null != type "> | |||
| and `type` = #{type} | |||
| and c.`type` = #{type} | |||
| </if> | |||
| <if test=" null != title and ''!=title"> | |||
| and `title` like concat('%', #{title},'%') | |||
| and c.`title` like concat('%', #{title},'%') | |||
| </if> | |||
| <if test=" null != isLandscape "> | |||
| and `is_landscape` = #{isLandscape} | |||
| and c.`is_landscape` = #{isLandscape} | |||
| </if> | |||
| <if test=" null != isPayment "> | |||
| and `is_payment` = #{isPayment} | |||
| and c.`is_payment` = #{isPayment} | |||
| </if> | |||
| <if test=" null != isPreview "> | |||
| and `is_preview` = #{isPreview} | |||
| and c.`is_preview` = #{isPreview} | |||
| </if> | |||
| <if test=" null != status"> | |||
| and `status` = #{status} | |||
| and c.`status` = #{status} | |||
| </if> | |||
| <if test="startdate != null"> | |||
| and `create_date` >= #{startdate} | |||
| and c.`create_date` >= #{startdate} | |||
| </if> | |||
| <if test="enddate != null"> | |||
| and `create_date` <= #{enddate} | |||
| and c.`create_date` <= #{enddate} | |||
| </if> | |||
| <if test=" null != businessId "> | |||
| and `business_id` = #{businessId} | |||
| and c.`business_id` = #{businessId} | |||
| </if> | |||
| <if test=" null != merchantId "> | |||
| and `merchant_id` = #{merchantId} | |||
| and c.`merchant_id` = #{merchantId} | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| and c.id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| #{idItem} | |||
| </foreach> | |||
| </if> | |||
| <if test=" null != sortColumns">order by ${sortColumns}</if> | |||
| order by c.`update_date` desc | |||
| <!--<if test=" null != sortColumns">order by ${sortColumns}</if>--> | |||
| </sql> | |||
| <select id="findList" parameterType="com.iformall.domain.po.tt.TtCoupon" resultMap="BaseResultMap"> | |||
| select | |||
| <include refid="allColumns"/> | |||
| from tt_coupon | |||
| from tt_coupon c | |||
| left join wx_merchant m on m.id = c.merchant_id | |||
| <include refid="dynamicWhereConditions"/> | |||
| </select> | |||
| <select id="selectById" parameterType="Long" resultMap="BaseResultMap"> | |||
| select <include refid="allColumns"/> from tt_coupon where id = #{id} | |||
| select <include refid="allColumns"/> | |||
| from tt_coupon c | |||
| left join wx_merchant m on m.id = c.merchant_id | |||
| where c.id = #{id} | |||
| </select> | |||
| <delete id="deleteById" parameterType="Long"> | |||
| @@ -0,0 +1,67 @@ | |||
| <?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.TtUserCollectMapper"> | |||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.tt.TtUserCollect"> | |||
| <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="coupon_id" jdbcType="BIGINT" property="couponId"/> | |||
| <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`, `user_id`, `coupon_id`, `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 != userId "> | |||
| and `user_id` = #{userId} | |||
| </if> | |||
| <if test=" null != couponId "> | |||
| and `coupon_id` = #{couponId} | |||
| </if> | |||
| <if test="startdate != null"> | |||
| and `create_date` >= #{startdate} | |||
| </if> | |||
| <if test="enddate != null"> | |||
| 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.tt.TtUserCollect" resultMap="BaseResultMap"> | |||
| select | |||
| <include refid="allColumns"/> | |||
| from tt_user_collect | |||
| <include refid="dynamicWhereConditions"/> | |||
| </select> | |||
| <delete id="deleteById" parameterType="Long"> | |||
| update tt_user_collect set is_del = 1,update_date=now() where id = #{id} | |||
| </delete> | |||
| </mapper> | |||
| @@ -0,0 +1,67 @@ | |||
| <?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.TtUserFollowMapper"> | |||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.tt.TtUserFollow"> | |||
| <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="merchern_id" jdbcType="BIGINT" property="merchernId"/> | |||
| <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`, `user_id`, `merchern_id`, `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 != userId "> | |||
| and `user_id` = #{userId} | |||
| </if> | |||
| <if test=" null != merchernId "> | |||
| and `merchern_id` = #{merchernId} | |||
| </if> | |||
| <if test="startdate != null"> | |||
| and `create_date` >= #{startdate} | |||
| </if> | |||
| <if test="enddate != null"> | |||
| 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.tt.TtUserFollow" resultMap="BaseResultMap"> | |||
| select | |||
| <include refid="allColumns"/> | |||
| from tt_user_follow | |||
| <include refid="dynamicWhereConditions"/> | |||
| </select> | |||
| <delete id="deleteById" parameterType="Long"> | |||
| update tt_user_follow set is_del = 1,update_date=now() where id = #{id} | |||
| </delete> | |||
| </mapper> | |||
| @@ -0,0 +1,81 @@ | |||
| <?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.TtVideoLibraryMapper"> | |||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.tt.TtVideoLibrary"> | |||
| <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="video_id" jdbcType="VARCHAR" property="videoId"/> | |||
| <result column="video_url" jdbcType="VARCHAR" property="videoUrl"/> | |||
| <result column="preview" jdbcType="VARCHAR" property="preview"/> | |||
| <result column="name" jdbcType="VARCHAR" property="name"/> | |||
| <result column="duration" jdbcType="VARCHAR" property="duration"/> | |||
| <result column="exceed_time" jdbcType="TIMESTAMP" property="exceedTime"/> | |||
| <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`, `video_id`, `video_url`, `preview`, `name`, `duration`, `exceed_time`,`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 != videoId and '' != videoId"> | |||
| and `video_id` = #{videoId} | |||
| </if> | |||
| <if test=" null != name and ''!=name"> | |||
| and `title` like concat('%', #{name},'%') | |||
| </if> | |||
| <if test="startdate != null"> | |||
| and `create_date` >= #{startdate} | |||
| </if> | |||
| <if test="enddate != null"> | |||
| 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.tt.TtVideoLibrary" resultMap="BaseResultMap"> | |||
| select | |||
| <include refid="allColumns"/> | |||
| from tt_video_library | |||
| <include refid="dynamicWhereConditions"/> | |||
| </select> | |||
| <delete id="deleteById" parameterType="Long"> | |||
| update tt_video_library set is_del = 1,update_date=now() where id = #{id} | |||
| </delete> | |||
| <select id="getByVideoId" parameterType="String" resultMap="BaseResultMap"> | |||
| select | |||
| <include refid="allColumns"/> | |||
| from tt_video_library | |||
| where `video_id` = #{videoId} | |||
| </select> | |||
| </mapper> | |||
| @@ -6,12 +6,19 @@ import java.text.SimpleDateFormat; | |||
| import java.util.Date; | |||
| import com.iformall.domain.po.MallUserInfo; | |||
| import com.iformall.domain.po.WxAppinfo; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.douyin.miniapp.api.TtMaService; | |||
| import com.iformall.service.WxAppinfoService; | |||
| import com.iformall.shiro.UserSession; | |||
| import com.iformall.utils.Constant; | |||
| import com.iformall.utils.IPUtil; | |||
| import com.iformall.utils.MaUtil; | |||
| import me.chanjar.weixin.common.error.WxErrorException; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.apache.shiro.SecurityUtils; | |||
| import org.apache.shiro.session.Session; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.WebDataBinder; | |||
| import org.springframework.web.bind.annotation.InitBinder; | |||
| import org.springframework.web.bind.annotation.RestController; | |||
| @@ -23,6 +30,9 @@ import javax.servlet.http.HttpServletRequest; | |||
| @RestController | |||
| public class BaseController { | |||
| @Autowired | |||
| private WxAppinfoService wxAppinfoService; | |||
| @InitBinder | |||
| public void InitBinder(WebDataBinder dataBinder) { | |||
| dataBinder.registerCustomEditor(Date.class, new PropertyEditorSupport() { | |||
| @@ -60,6 +70,22 @@ public class BaseController { | |||
| // return tenantId; | |||
| // } | |||
| public TtMaService getWeappServiceByAppInfo(WxAppinfo appinfo) { | |||
| TtMaService ttMaService = MaUtil.getTtappService(appinfo); | |||
| if (StringUtils.isBlank(appinfo.getAccessToken())) { | |||
| // 如果没有accessToken,主动获取保存到数据库中,下次访问可以拿来使用 | |||
| updateAppAccessToken(appinfo, ttMaService); | |||
| } else { | |||
| // 检查token是否已过期, 1小时就重新获取 | |||
| Date curDate = new Date(); | |||
| if (curDate.getTime() > appinfo.getLastTokenTime().getTime() + Constant.H_EXPIRE) { | |||
| updateAppAccessToken(appinfo, ttMaService); | |||
| } | |||
| } | |||
| return ttMaService; | |||
| } | |||
| /** | |||
| * 返回租户信息 | |||
| * 集团版帐号tenantId为空,parentTenantId为集团tenantId | |||
| @@ -106,6 +132,32 @@ public class BaseController { | |||
| return null; | |||
| } | |||
| /** | |||
| * WxAppInfo更新accessToken | |||
| * | |||
| * @param wxAppinfo | |||
| * @param TtMaService | |||
| */ | |||
| private void updateAppAccessToken(WxAppinfo wxAppinfo, TtMaService TtMaService) { | |||
| try { | |||
| String accessToken = TtMaService.getAccessToken(true); | |||
| WxAppinfo updateApp = new WxAppinfo(); | |||
| updateApp.setId(wxAppinfo.getId()); | |||
| updateApp.setAccessToken(accessToken); | |||
| updateApp.setLastTokenTime(new Date()); | |||
| updateApp.setExpiresIn(7200); | |||
| wxAppinfo.setAccessToken(updateApp.getAccessToken()); | |||
| wxAppinfo.setLastTokenTime(updateApp.getLastTokenTime()); | |||
| wxAppinfo.setExpiresIn(updateApp.getExpiresIn()); | |||
| wxAppinfoService.saveOrUpdate(updateApp); | |||
| } catch (WxErrorException e) { | |||
| e.printStackTrace(); | |||
| } catch (Exception e) { | |||
| e.printStackTrace(); | |||
| } | |||
| } | |||
| public String getIpAddr() { | |||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | |||
| String ipaddress = IPUtil.getIpAddr(request); | |||
| @@ -0,0 +1,27 @@ | |||
| package com.iformall.controller.basic; | |||
| import com.iformall.ueditor.ActionEnter; | |||
| import io.swagger.annotations.Api; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.RequestMapping; | |||
| import org.springframework.web.bind.annotation.ResponseBody; | |||
| import org.springframework.web.bind.annotation.RestController; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| @RestController | |||
| @RequestMapping("/ue") | |||
| @Api(description = "网页bannner图接口") | |||
| public class UeditorController { | |||
| @Autowired | |||
| private ActionEnter actionEnter; | |||
| @ResponseBody | |||
| @RequestMapping("/ueditor/exec") | |||
| public Object exe(HttpServletRequest request){ | |||
| return actionEnter.exec(request); | |||
| } | |||
| } | |||
| @@ -1,23 +1,36 @@ | |||
| package com.iformall.controller.tt; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxBusiness; | |||
| import com.iformall.domain.po.WxMerchant; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.po.tt.TtCoupon; | |||
| import com.iformall.domain.po.tt.TtVideoLibrary; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.service.WxBusinessService; | |||
| import com.iformall.service.WxFlowService; | |||
| import com.iformall.service.WxMerchantService; | |||
| import com.iformall.service.tt.TtCouponService; | |||
| import com.iformall.service.tt.TtVideoLibraryService; | |||
| import com.iformall.utils.RedisLock; | |||
| 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 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 java.util.List; | |||
| @RestController | |||
| @RequestMapping("ttCoupon") | |||
| @Api(description = "") | |||
| @@ -28,6 +41,21 @@ public class TtCouponController extends BaseController { | |||
| @Autowired | |||
| private TtCouponService ttCouponService; | |||
| @Autowired | |||
| private TtVideoLibraryService ttVideoLibraryService; | |||
| @Autowired | |||
| private WxMerchantService wxMerchantService; | |||
| @Autowired | |||
| private WxFlowService wxFlowService; | |||
| @Autowired | |||
| VideoFactory videoFactory; | |||
| @Autowired | |||
| String videoType; | |||
| @Autowired | |||
| RedisLock redisLock; | |||
| @@ -38,8 +66,14 @@ public class TtCouponController extends BaseController { | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "-列表") | |||
| public ResultData list(@ModelAttribute TtCoupon record, Integer pageNum, Integer pageSize, Integer dataType) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponController::list"); | |||
| logger.debug("[" + getIpAddr() + "] TtCouponController::list"); | |||
| if (record == null) record = new TtCoupon(); | |||
| record.updateTenantInfo(getTenantInfo()); | |||
| // if(record.getType() == null || record.getType().equals(EnumTtCouponType.COUPON_SINGLE.getCode())){ | |||
| // record.setType(EnumTtCouponType.COUPON_SINGLE.getCode()); | |||
| // }else{ | |||
| // record.setType(EnumTtCouponType.COUPON_COLUMN.getCode()); | |||
| // } | |||
| return new ResultData(ttCouponService.listAsPage(record, pageNum, pageSize)); | |||
| } | |||
| @@ -47,10 +81,91 @@ public class TtCouponController extends BaseController { | |||
| @PostMapping("add") | |||
| @SystemControllerLog(description = "-新增") | |||
| public ResultData add(@RequestBody TtCoupon record) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponController::add"); | |||
| logger.debug("[" + getIpAddr() + "] TtCouponController::add"); | |||
| if(record == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||
| } | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| record.updateTenantInfo(tenantEntity); | |||
| if(record.getId() != null){ | |||
| TtCoupon coupon = ttCouponService.getById(record.getId()); | |||
| if (null == coupon || EnumDelFlag.YES.getCode().equals(record.getIsDel())) { | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR,"找不到课程,或课程已删除"); | |||
| } | |||
| if(!coupon.getStatus().equals(EnumTtCouponStatus.TTCOUPON_STATUS_DRAFT.getCode()) | |||
| && !coupon.getStatus().equals(EnumTtCouponStatus.TTCOUPON_STATUS_REJECT.getCode())){ | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR,"该课程状态不允许修改"); | |||
| } | |||
| } | |||
| if(record.getMerchantId() == null){ | |||
| WxMerchant merchantQ = new WxMerchant(); | |||
| merchantQ.updateTenantInfo(tenantEntity); | |||
| merchantQ.setStatus(EnumMerchantStatus.VALID.getCode()); | |||
| List<WxMerchant> list = wxMerchantService.findList(merchantQ); | |||
| if(list != null && list.size() > 0){ | |||
| record.setMerchantId(list.get(0).getId()); | |||
| } | |||
| } | |||
| if(record.getMerchantId() == null){ | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR,"找不到作者"); | |||
| } | |||
| if(record.getBusinessId() == null){ | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR,"未选择分类"); | |||
| } | |||
| if(record.getType() == null){ | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR,"type为空"); | |||
| } | |||
| if(record.getType().equals(EnumTtCouponType.COUPON_SINGLE.getCode())){ | |||
| if(StringUtils.isBlank(record.getVideoId())){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"未上传视频"); | |||
| }else{ | |||
| VideUploadResult result = videoFactory.getExcutor(videoType).getVideoDetail(record.getVideoId()); | |||
| if(result.isSuccess()){ | |||
| record.setVideoTime(result.getDuration()); | |||
| record.setVideoUrl(result.getVideoUrl()); | |||
| TtVideoLibrary video = new TtVideoLibrary(); | |||
| video.updateTenantInfo(tenantEntity); | |||
| video.setVideoId(record.getVideoId()); | |||
| video.setVideoUrl(result.getVideoUrl()); | |||
| video.setPreview(result.getCoverURL()); | |||
| video.setDuration(result.getDuration()); | |||
| ttVideoLibraryService.saveOrUpdate(video); | |||
| }else{ | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR,result.getMsg()); | |||
| } | |||
| } | |||
| }else if(record.getType().equals(EnumTtCouponType.COUPON_COLUMN.getCode())){ | |||
| if(record.getColumnCoupons() != null && record.getColumnCoupons().size() > 0){ | |||
| for (TtCoupon ttc:record.getColumnCoupons()) { | |||
| if(StringUtils.isBlank(ttc.getVideoId())) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "部分未上传视频"); | |||
| } | |||
| VideUploadResult result = videoFactory.getExcutor(videoType).getVideoDetail(ttc.getVideoId()); | |||
| if(result.isSuccess()){ | |||
| ttc.setVideoTime(result.getDuration()); | |||
| ttc.setVideoUrl(result.getVideoUrl()); | |||
| TtVideoLibrary video = new TtVideoLibrary(); | |||
| video.updateTenantInfo(tenantEntity); | |||
| video.setVideoId(record.getVideoId()); | |||
| video.setVideoUrl(result.getVideoUrl()); | |||
| video.setPreview(result.getCoverURL()); | |||
| video.setDuration(result.getDuration()); | |||
| ttVideoLibraryService.saveOrUpdate(video); | |||
| }else{ | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR,result.getMsg()); | |||
| } | |||
| } | |||
| }else{ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "未上传视频"); | |||
| } | |||
| }else{ | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR,"未识别type类型"); | |||
| } | |||
| // record.setType(EnumTtCouponType.COUPON_SINGLE.getCode()); | |||
| ResultData resultData = ttCouponService.saveOrUpdate(record); | |||
| if (resultData.code != 200) { | |||
| return resultData; | |||
| @@ -61,8 +176,9 @@ public class TtCouponController extends BaseController { | |||
| // record.getFlowParams().put("businessId",record.getId()); | |||
| // wxFlowService.start(record.getFlowParams(), getUserId(), getUser().getName(), tenantEntity); | |||
| // //修改coupon applyStatus状态为审核中 | |||
| // record.setPutApplyStatus(EnumRentContractAppStatus.APPLYING.getCode()); | |||
| // record.setStatus(EnumTtCouponStatus.TTCOUPON_STATUS_EXAMINE.getCode()); | |||
| // } | |||
| return resultData; | |||
| } | |||
| @@ -70,44 +186,80 @@ public class TtCouponController extends BaseController { | |||
| @PostMapping("update") | |||
| @SystemControllerLog(description = "更新") | |||
| public ResultData update(@RequestBody TtCoupon record) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponController::update"); | |||
| logger.debug("[" + getIpAddr() + "] TtCouponController::update"); | |||
| if (record.getId() == null) { | |||
| return new ResultData(ResultData.ERROR, "缺少id"); | |||
| } | |||
| record.updateTenantInfo(getTenantInfo()); | |||
| if(EnumDelFlag.YES.getCode().equals(record.getIsDel())){ | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| record.updateTenantInfo(tenantEntity); | |||
| TtCoupon coupon = ttCouponService.getById(record.getId()); | |||
| if (null == coupon || EnumDelFlag.YES.getCode().equals(record.getIsDel())) { | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR,"找不到课程,或课程已删除"); | |||
| } | |||
| TtCoupon coupon = ttCouponService.getById(record.getId()); | |||
| if (null == coupon) { | |||
| return new ResultData(ResultData.ERROR, "未查询到数据。"+record.getId()); | |||
| if(record.getMerchantId() == null){ | |||
| WxMerchant merchantQ = new WxMerchant(); | |||
| merchantQ.updateTenantInfo(tenantEntity); | |||
| merchantQ.setStatus(EnumMerchantStatus.VALID.getCode()); | |||
| List<WxMerchant> list = wxMerchantService.findList(merchantQ); | |||
| if(list != null && list.size() > 0){ | |||
| record.setMerchantId(list.get(0).getId()); | |||
| } | |||
| } | |||
| if(record.getMerchantId() == null){ | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR,"找不到作者"); | |||
| } | |||
| if(record.getBusinessId() == null){ | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR,"未选择分类"); | |||
| } | |||
| if(!record.getMerchantId().equals(coupon.getMerchantId())){ | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR,"作者课程不匹配"); | |||
| } | |||
| if(StringUtils.isBlank(record.getVideoId())){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"未上传视频"); | |||
| } | |||
| VideUploadResult result = videoFactory.getExcutor(videoType).getVideoDetail(record.getVideoId()); | |||
| if(result.isSuccess()){ | |||
| record.setVideoTime(result.getDuration()); | |||
| TtVideoLibrary video = new TtVideoLibrary(); | |||
| video.updateTenantInfo(tenantEntity); | |||
| video.setVideoId(record.getVideoId()); | |||
| video.setVideoUrl(result.getVideoUrl()); | |||
| video.setPreview(result.getCoverURL()); | |||
| video.setDuration(result.getDuration()); | |||
| ttVideoLibraryService.saveOrUpdate(video); | |||
| }else{ | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR,result.getMsg()); | |||
| } | |||
| //启动审批流 | |||
| // if (record.getFlowParams() != null && record.getFlowParams().size() > 0) { | |||
| // logger.info("------coupon.update().businessType:"+record.getFlowParams().get("businessType")); | |||
| // record.setType(EnumTtCouponType.COUPON_SINGLE.getCode()); | |||
| ResultData resultData = ttCouponService.saveOrUpdate(record); | |||
| if (resultData.code != 200) { | |||
| return resultData; | |||
| } | |||
| //启动投放审批 | |||
| // if(record.getFlowParams() !=null && record.getFlowParams().size()>0) { | |||
| // record.getFlowParams().put("businessId",record.getId()); | |||
| // wxFlowService.start(record.getFlowParams(), getUserId(), getUser().getName(), getTenantInfo()); | |||
| // //作废审批 | |||
| // if (EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode().equals(record.getStatus())) { | |||
| // record.setCancleApplyStatus(EnumRentContractAppStatus.APPLYING.getCode()); | |||
| // return new ResultData(record); | |||
| // } else { | |||
| // //投放审批 | |||
| // record.setPutApplyStatus(EnumRentContractAppStatus.APPLYING.getCode()); | |||
| // } | |||
| // wxFlowService.start(record.getFlowParams(), getUserId(), getUser().getName(), tenantEntity); | |||
| // //修改coupon applyStatus状态为审核中 | |||
| // record.setStatus(EnumTtCouponStatus.TTCOUPON_STATUS_EXAMINE.getCode()); | |||
| // } | |||
| return ttCouponService.saveOrUpdate(record); | |||
| return resultData; | |||
| } | |||
| @ApiOperation("根据id删除接口") | |||
| @GetMapping("/del") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "券投放-删除") | |||
| public ResultData delete(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponController::delete"); | |||
| @SystemControllerLog(description = "-删除") | |||
| public ResultData delete(@RequestParam Long id) { | |||
| logger.debug("[" + getIpAddr() + "] TtCouponController::delete"); | |||
| if (id == null) { | |||
| return new ResultData(ResultData.ERROR, "缺少id"); | |||
| } | |||
| ttCouponService.deleteById(id); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| } | |||
| @@ -115,10 +267,37 @@ public class TtCouponController extends BaseController { | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "券投放-查询") | |||
| @SystemControllerLog(description = "") | |||
| public ResultData findById(@RequestParam Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponController::findById"); | |||
| return new ResultData(ttCouponService.getById(id)); | |||
| logger.debug("[" + getIpAddr() + "] TtCouponController::findById"); | |||
| if (id == null) { | |||
| return new ResultData(ResultData.ERROR, "缺少id"); | |||
| } | |||
| return new ResultData(ttCouponService.detail(id)); | |||
| } | |||
| @ApiOperation("根据上架") | |||
| @GetMapping("/puton") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "") | |||
| public ResultData puton(@RequestParam Long id) { | |||
| logger.debug("[" + getIpAddr() + "] TtCouponController::findById");if (id == null) { | |||
| return new ResultData(ResultData.ERROR, "缺少id"); | |||
| } | |||
| return ttCouponService.puton(id); | |||
| } | |||
| @ApiOperation("根据下架") | |||
| @GetMapping("/putoff") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "") | |||
| public ResultData putoff(@RequestParam Long id) { | |||
| logger.debug("[" + getIpAddr() + "] TtCouponController::findById"); | |||
| if (id == null) { | |||
| return new ResultData(ResultData.ERROR, "缺少id"); | |||
| } | |||
| return ttCouponService.putoff(id); | |||
| } | |||
| } | |||
| @@ -0,0 +1,80 @@ | |||
| package com.iformall.controller.tt; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxAppinfo; | |||
| import com.iformall.domain.po.tt.TtOrder; | |||
| import com.iformall.enums.EnumPayWay; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.WxAppinfoService; | |||
| import com.iformall.service.WxCUserBasicInfoService; | |||
| import com.iformall.service.tt.TtOrderService; | |||
| import com.iformall.utils.Constant; | |||
| 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.Map; | |||
| @RestController | |||
| @RequestMapping("ttOrder") | |||
| @Api(description = "订单相关接口") | |||
| public class TtOrderController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private TtOrderService ttOrderService; | |||
| @Autowired | |||
| private WxAppinfoService wxAppinfoService; | |||
| @Autowired | |||
| private WxCUserBasicInfoService wxCUserBasicInfoService; | |||
| @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 TtOrder order, Integer pageNum, Integer pageSize) { | |||
| if (order == null){ | |||
| order = new TtOrder(); | |||
| } | |||
| return new ResultData(ttOrderService.listAsPage(order, pageNum, pageSize)); | |||
| } | |||
| @ApiOperation("订单详情接口") | |||
| @GetMapping("detail") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "orderId", value = "订单id", dataType = "String", paramType = "query", required = true) | |||
| }) | |||
| public ResultData detail(String orderId) { | |||
| if (StringUtils.isBlank(orderId) || orderId.equalsIgnoreCase(Constant.UNDEFINED)) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| Long id; | |||
| try { | |||
| id = Long.valueOf(orderId); | |||
| } catch (NumberFormatException e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "orderId: " + orderId + ", e: " + e.getMessage()); | |||
| } | |||
| TtOrder order = ttOrderService.detail(id,null); | |||
| return new ResultData(order); | |||
| } | |||
| } | |||
| @@ -1,41 +1,9 @@ | |||
| package com.iformall.controller.video; | |||
| import com.alibaba.fastjson.JSONArray; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.annotation.UserDataRuleAnnotation; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.MallUserInfo; | |||
| import com.iformall.domain.po.WxBillProperty; | |||
| import com.iformall.domain.po.WxMallBuilding; | |||
| import com.iformall.domain.po.WxMallFloor; | |||
| import com.iformall.domain.po.WxMerchant; | |||
| import com.iformall.domain.po.WxPropertyContract; | |||
| import com.iformall.domain.po.WxRentContract; | |||
| import com.iformall.domain.po.WxShop; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.po.base.BaseEntity.SortField; | |||
| import com.iformall.enums.EnumContractOperationType; | |||
| import com.iformall.enums.EnumContractType; | |||
| import com.iformall.enums.EnumFlowContractType; | |||
| import com.iformall.enums.EnumFlowKey; | |||
| import com.iformall.enums.EnumIsPreview; | |||
| import com.iformall.enums.EnumRentContractAppStatus; | |||
| import com.iformall.enums.EnumRentContractStatus; | |||
| import com.iformall.enums.EnumRentShopType; | |||
| import com.iformall.enums.EnumRentStartType; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.mapper.WxPropertyContractMapper; | |||
| import com.iformall.service.WxBillPropertyService; | |||
| import com.iformall.service.WxMallBuildingService; | |||
| import com.iformall.service.WxMallFloorService; | |||
| import com.iformall.service.WxPropertyContractService; | |||
| import com.iformall.service.WxRentPropertyContractService; | |||
| import com.iformall.service.WxShopService; | |||
| import com.iformall.video.VideoFactory; | |||
| import com.iformall.video.entity.VideUploadResult; | |||
| @@ -50,13 +18,6 @@ import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import org.springframework.web.multipart.MultipartFile; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import java.util.ArrayList; | |||
| import java.util.Date; | |||
| import java.util.HashMap; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| /** | |||
| @@ -69,7 +30,7 @@ public class VideoController extends BaseController { | |||
| @Autowired | |||
| VideoFactory videoFactory; | |||
| @Autowired | |||
| String videoType; | |||
| @@ -80,7 +41,7 @@ public class VideoController extends BaseController { | |||
| VideUploadResult result = videoFactory.getExcutor(videoType).uploadLocalVideo("123123213", "/root/111.mp4"); | |||
| return new ResultData(result); | |||
| } | |||
| /** | |||
| * 上传视频 | |||
| * | |||
| @@ -90,11 +51,21 @@ public class VideoController extends BaseController { | |||
| */ | |||
| @PostMapping(value = "/upload", consumes = "multipart/*", headers = "content-type=multipart/form-data") | |||
| @ApiOperation("上传视频") | |||
| @SystemControllerLog(description = "文件上传") | |||
| public ResultData awsfileUpload(@RequestParam("file") MultipartFile multiReq,@RequestParam Map<String, String> param) { | |||
| public ResultData upload(@RequestParam("file") MultipartFile multiReq,@RequestParam Map<String, String> param) { | |||
| try { | |||
| String title = param.get("title"); | |||
| VideUploadResult result = videoFactory.getExcutor(videoType).uploadLocalVideo(title, multiReq.getInputStream()); | |||
| String title = param.get("title"); | |||
| int dot = multiReq.getOriginalFilename().lastIndexOf('.'); | |||
| String fileFormat = ""; | |||
| if (dot >= 0) { | |||
| fileFormat = multiReq.getOriginalFilename().substring(dot, multiReq.getOriginalFilename().length()); | |||
| if(StringUtils.isBlank(title)){ | |||
| title = multiReq.getOriginalFilename().substring(0,dot); | |||
| } | |||
| } | |||
| if(!fileFormat.endsWith("mp4")){ | |||
| return new ResultData(ErrorCode.PICTURE_ENDWIDTH_ERROR); | |||
| } | |||
| VideUploadResult result = videoFactory.getExcutor(videoType).uploadLocalVideo(title, multiReq.getInputStream(),fileFormat); | |||
| return new ResultData(result); | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| @@ -102,4 +73,46 @@ public class VideoController extends BaseController { | |||
| } | |||
| } | |||
| /** | |||
| * 上传视频 | |||
| * | |||
| * @param | |||
| * @return | |||
| * @throws Exception | |||
| */ | |||
| @GetMapping(value = "/uploadProgress") | |||
| @ApiOperation("上传视频进度") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "videoId", value = "视频编号", dataType = "String", paramType = "query", required = true)}) | |||
| public ResultData uploadProgress(String videoId) { | |||
| try { | |||
| String result = videoFactory.getExcutor(videoType).getVedioUploadProgress(videoId); | |||
| return new ResultData(result); | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.PICTURE_ANALYZING_ERROR); | |||
| } | |||
| } | |||
| /** | |||
| * 获取视频信息 | |||
| * | |||
| * @param | |||
| * @return | |||
| * @throws Exception | |||
| */ | |||
| @GetMapping(value = "/getVideoDetail") | |||
| @ApiOperation("上传视频进度") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "videoId", value = "视频编号", dataType = "String", paramType = "query", required = true)}) | |||
| public ResultData getVideoDetail(String videoId) { | |||
| try { | |||
| VideUploadResult result = videoFactory.getExcutor(videoType).getVideoDetail(videoId); | |||
| return new ResultData(result); | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR); | |||
| } | |||
| } | |||
| } | |||
| @@ -22,7 +22,8 @@ public class UrlCheck { | |||
| || url.contains("/kwMeter/import") | |||
| || url.contains("/wxImportTemplate/importTemplate") | |||
| || url.contains("/invest/customer/importCustomer") | |||
| || url.contains("/alipay/imageUpload"); | |||
| || url.contains("/alipay/imageUpload") | |||
| || url.contains("/video/upload"); | |||
| } | |||
| } | |||
| @@ -1,7 +1,9 @@ | |||
| package com.iformall.controller; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.tt.TtCoupon; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.tt.TtCouponService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| @@ -28,7 +30,7 @@ public class TtCouponController extends BaseController { | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| public ResultData list(@ModelAttribute TtCoupon record, Integer pageNum, Integer pageSize, Integer dataType) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponController::list"); | |||
| logger.debug("[" + getIpAddr() + "] TtCouponController::list"); | |||
| if (record == null) record = new TtCoupon(); | |||
| return new ResultData(ttCouponService.listAsPage(record, pageNum, pageSize)); | |||
| } | |||
| @@ -37,8 +39,33 @@ public class TtCouponController extends BaseController { | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| public ResultData findById(@RequestParam Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponController::findById"); | |||
| return new ResultData(ttCouponService.getById(id)); | |||
| logger.debug("[" + getIpAddr() + "] TtCouponController::findById"); | |||
| if (id == null) { | |||
| return new ResultData(ResultData.ERROR, "缺少id"); | |||
| } | |||
| return new ResultData(ttCouponService.detail(id)); | |||
| } | |||
| @ApiOperation("收藏") | |||
| @GetMapping("/collectCoupon") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| public ResultData collectCoupon(@RequestParam Long id) { | |||
| logger.debug("[" + getIpAddr() + "] TtCouponController::findById"); | |||
| if (id == null) { | |||
| return new ResultData(ResultData.ERROR, "缺少id"); | |||
| } | |||
| TtCoupon byId = ttCouponService.getById(id); | |||
| if(byId == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"找不到课程"); | |||
| } | |||
| Long memberId; | |||
| try { | |||
| memberId = getMemberId(); | |||
| } catch (MallinkException e) { | |||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||
| } | |||
| ttCouponService.collectCoupon(getTenantInfo(),memberId,byId.getId()); | |||
| return new ResultData(); | |||
| } | |||
| } | |||
| @@ -1,27 +1,14 @@ | |||
| package com.iformall.controller; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.dto.OrderSaveDto; | |||
| import com.iformall.domain.po.WxCUserBasicInfo; | |||
| import com.iformall.domain.po.WxCoupon; | |||
| import com.iformall.domain.po.WxOrder; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.po.tt.TtOrder; | |||
| import com.iformall.domain.vo.WxCouponCVo; | |||
| import com.iformall.domain.vo.WxOrderCouponPressVo; | |||
| import com.iformall.domain.vo.WxOrderCouponVo; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.WxCUserBasicInfoService; | |||
| import com.iformall.service.WxCouponChannelService; | |||
| import com.iformall.service.WxCouponService; | |||
| import com.iformall.service.WxOrderService; | |||
| import com.iformall.service.*; | |||
| import com.iformall.service.tt.TtOrderService; | |||
| import com.iformall.utils.Constant; | |||
| import com.iformall.utils.RedisLock; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| @@ -30,11 +17,9 @@ 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 java.util.Date; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import java.util.Map; | |||
| @RestController | |||
| @@ -47,24 +32,12 @@ public class TtOrderController extends BaseController { | |||
| @Autowired | |||
| private TtOrderService ttOrderService; | |||
| WxOrderService wxOrderService; | |||
| @Autowired | |||
| private WxCouponChannelService wxCouponChannelService; | |||
| @Autowired | |||
| private WxCouponService wxCouponService; | |||
| private WxAppinfoService wxAppinfoService; | |||
| @Autowired | |||
| private WxCUserBasicInfoService wxCUserBasicInfoService; | |||
| @Autowired | |||
| @Qualifier("couponDetailRedisTemplate") | |||
| RedisTemplate<String, WxCouponCVo> cdRedisTemplate; | |||
| @Autowired | |||
| RedisLock redisLock; | |||
| @ApiOperation("分页订单列表接口") | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @@ -164,4 +137,90 @@ public class TtOrderController extends BaseController { | |||
| return new ResultData(order); | |||
| } | |||
| /** | |||
| * tt支付 | |||
| * @param paramMap | |||
| * @param request | |||
| * @return | |||
| * @throws Exception | |||
| */ | |||
| //@ApiOperation(value = "发起小程序支付订单", notes = "{\"orderId\":\"string\"}") | |||
| @RequestMapping(value = "/createPay", method = RequestMethod.POST) | |||
| public ResultData _create(@RequestBody Map<String, String> paramMap, HttpServletRequest request) throws Exception { | |||
| logger.info("/api/pay/create" + paramMap.toString()); | |||
| String orderIdStr = paramMap.get("orderId"); | |||
| if (StringUtils.isBlank(orderIdStr)) { | |||
| logger.info("orderId不能为空: " + paramMap.toString()); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "orderId不能为空"); | |||
| } | |||
| Long orderId; | |||
| try { | |||
| orderId = Long.valueOf(orderIdStr); | |||
| } catch (NumberFormatException e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "orderId: " + orderIdStr + ", e: " + e.getMessage()); | |||
| } | |||
| Long memberId; | |||
| try { | |||
| memberId = getMemberId(); | |||
| } catch (MallinkException e) { | |||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||
| } | |||
| WxAppinfo cAppInfo = wxAppinfoService.getCAppInfo(getTenantInfo(), EnumPayWay.PAY_WAY_TT); | |||
| if(cAppInfo == null){ | |||
| return new ResultData(ErrorCode.APP_ID_NOT_ENABLE); | |||
| } | |||
| return ttOrderService.createPay(getTenantInfo(),orderId,memberId,cAppInfo); | |||
| } | |||
| @ApiOperation(value = "更新支付订单状态", notes = "{\"payOrderId\":\"string\",\"orderId\":\"string\",\"status\":integer,\"reason\":\"string\"}") | |||
| @PostMapping("/updateOrderStatus") | |||
| public ResultData updateOrderStatus(@RequestBody Map<String, Object> paramMap) { | |||
| logger.info("/api/pay/updateOrderStatus" + paramMap.toString()); | |||
| String orderIdStr = (String) paramMap.get("orderId"); | |||
| String codeStr = (String) paramMap.get("code"); | |||
| if (StringUtils.isBlank(orderIdStr)) { | |||
| logger.info("orderId不能为空: " + paramMap.toString()); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "orderId不能为空"); | |||
| } | |||
| if (StringUtils.isBlank(codeStr)) { | |||
| logger.info("code不能为空: " + paramMap.toString()); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "code不能为空"); | |||
| } | |||
| Long orderId; | |||
| try { | |||
| orderId = Long.valueOf(orderIdStr); | |||
| } catch (NumberFormatException e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "orderId: " + orderIdStr + ", e: " + e.getMessage()); | |||
| } | |||
| Integer code; | |||
| try { | |||
| code = Integer.valueOf(codeStr); | |||
| } catch (NumberFormatException e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "code: " + codeStr + ", e: " + e.getMessage()); | |||
| } | |||
| Long memberId; | |||
| try { | |||
| memberId = getMemberId(); | |||
| } catch (MallinkException e) { | |||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||
| } | |||
| WxAppinfo cAppInfo = wxAppinfoService.getCAppInfo(getTenantInfo(), EnumPayWay.PAY_WAY_TT); | |||
| if (cAppInfo == null) { | |||
| return new ResultData(ErrorCode.APP_ID_NOT_ENABLE); | |||
| } | |||
| if(code.intValue() == 0){ | |||
| return ttOrderService.updateOrderStatus(getTenantInfo(),orderId,memberId,cAppInfo); | |||
| }else{ | |||
| return new ResultData(); | |||
| } | |||
| } | |||
| } | |||
| @@ -1,223 +0,0 @@ | |||
| package com.iformall.controller; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.IdWorker; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.po.tt.TtCUser; | |||
| import com.iformall.enums.EnumCreditLockedStatus; | |||
| import com.iformall.enums.EnumOrderStatus; | |||
| import com.iformall.enums.EnumPayStatus; | |||
| import com.iformall.enums.EnumPayWay; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.*; | |||
| import com.iformall.service.pay.entity.PayExtraParam; | |||
| import com.iformall.utils.IPUtil; | |||
| import io.swagger.annotations.Api; | |||
| 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.Map; | |||
| @RestController | |||
| @RequestMapping("/api/pay") | |||
| @Api(description = "支付相关接口") | |||
| public class TtPayOrderController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxPayOrderService wxPayOrderService; | |||
| @Autowired | |||
| private WxOrderService wxOrderService; | |||
| @Autowired | |||
| private WxCUserBasicInfoService wxCUserBasicInfoService; | |||
| @Autowired | |||
| private WxPayAccountService wxPayAccountService; | |||
| @Autowired | |||
| private WxCouponService wxCouponService; | |||
| @Autowired | |||
| private WxAppinfoService wxAppinfoService; | |||
| /** | |||
| * 微信支付 | |||
| * @param paramMap | |||
| * @param request | |||
| * @return | |||
| * @throws Exception | |||
| */ | |||
| //@ApiOperation(value = "发起微信小程序支付订单", notes = "{\"orderId\":\"string\"}") | |||
| @RequestMapping(value = "/create", method = RequestMethod.POST) | |||
| public ResultData _create(@RequestBody Map<String, String> paramMap, HttpServletRequest request) throws Exception { | |||
| logger.info("/api/pay/create" + paramMap.toString()); | |||
| String orderIdStr = paramMap.get("orderId"); | |||
| if (StringUtils.isBlank(orderIdStr)) { | |||
| logger.info("orderId不能为空: " + paramMap.toString()); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "orderId不能为空"); | |||
| } | |||
| TtCUser user = getTtCUser(); | |||
| if (!user.basicInfoIs()) { | |||
| logger.error("暂未成为会员,请授权手机号"); | |||
| return new ResultData(ErrorCode.USER_IS_NOT_MEMBER.getCode(), "暂未成为会员,请授权手机号"); | |||
| } | |||
| return _create(orderIdStr,user.getUserId(),EnumPayWay.PAY_WAY_TT,user.getAppId(),new PayExtraParam("openId",user.getOpenId()),request); | |||
| } | |||
| private ResultData _create(String orderIdStr,Long userId, EnumPayWay payWay,String appId,PayExtraParam parm,HttpServletRequest request) { | |||
| WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoService.getById(userId,getTenantInfo().getFinalTenantId()); | |||
| if ( null == wxCUserBasicInfo) { | |||
| logger.error("会员用户不存在."+userId); | |||
| return new ResultData(ErrorCode.USER_IS_EMPTY.getCode(),"会员用户不存在."+userId); | |||
| } | |||
| if (null != wxCUserBasicInfo && EnumCreditLockedStatus.CLOSE.getCode().equals(wxCUserBasicInfo.getStatus())) { | |||
| return new ResultData(ErrorCode.MEMBER_IS_LOCKED); | |||
| } | |||
| WxAppinfo appInfo = wxAppinfoService.getByAppId(appId); | |||
| if(appInfo == null) { | |||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | |||
| } | |||
| Long orderId = 0L; | |||
| try { | |||
| orderId = Long.valueOf(orderIdStr); | |||
| } catch (NumberFormatException e) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "orderId参数不正确"); | |||
| } | |||
| WxPayOrder record = new WxPayOrder(); | |||
| record.setOrderId(orderId); | |||
| try { | |||
| record.setIp(IPUtil.getIpAddr(request)); | |||
| return wxPayOrderService.createPayOrder(appInfo, wxCUserBasicInfo, record, payWay,parm); | |||
| } catch (MallinkException e) { | |||
| logger.error("payment wechat, order create error, req 2: " + record.toString() + ", e:" + e.getMessage()); | |||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||
| } catch (Exception e) { | |||
| logger.error("payment wechat, order create error, req 3: " + record.toString() + ", e:" + e.getMessage()); | |||
| return new ResultData(ErrorCode.PAY_ORDER_ERROR, e.getMessage()); | |||
| } | |||
| } | |||
| @ApiOperation(value = "更新支付订单状态", notes = "{\"payOrderId\":\"string\",\"orderId\":\"string\",\"status\":integer,\"reason\":\"string\"}") | |||
| @PostMapping("/updatePayOrder") | |||
| public ResultData updatePayOrder(@RequestBody Map<String, Object> paramMap) { | |||
| logger.info("/api/pay/updatePayOrder" + paramMap.toString()); | |||
| String payOrderIdStr = (String) paramMap.get("payOrderId"); | |||
| String orderIdStr = (String) paramMap.get("orderId"); | |||
| String reasonStr = (String) paramMap.get("reason"); | |||
| Integer status = (Integer) paramMap.get("status"); | |||
| if (StringUtils.isBlank(orderIdStr)) { | |||
| logger.info("orderId不能为空: " + paramMap.toString()); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "orderId不能为空"); | |||
| } | |||
| Long payOrderId = 0L, orderId = 0L; | |||
| try { | |||
| orderId = Long.valueOf(orderIdStr); | |||
| } catch (NumberFormatException e) { | |||
| logger.error("orderId参数不正确: " + paramMap.toString() + ", e:" + e.getMessage()); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "orderId参数不正确"); | |||
| } | |||
| if (!StringUtils.isBlank(payOrderIdStr)) { | |||
| try { | |||
| payOrderId = Long.valueOf(payOrderIdStr); | |||
| } catch (NumberFormatException e) { | |||
| logger.error("payOrderId参数不正确: " + paramMap.toString() + ", e:" + e.getMessage()); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "payOrderId参数不正确"); | |||
| } | |||
| } | |||
| if(payOrderIdStr.equalsIgnoreCase("0")) { | |||
| // 免费券直接返回成功 | |||
| return new ResultData(Result.SUCCESS, "免费券支付状态更新成功"); | |||
| } | |||
| WxPayOrder payOrder = new WxPayOrder(); | |||
| payOrder.setId(payOrderId); | |||
| payOrder.setPayOrderNo(String.valueOf(payOrderId)); | |||
| payOrder.setOrderId(orderId); | |||
| payOrder.setPayOrderStatus(status); | |||
| payOrder.setFailReason(reasonStr); | |||
| payOrder.updateTenantInfo(getTenantInfo()); | |||
| payOrder.setPayVendor(EnumPayWay.PAY_WAY_WECHAT.getCode()); | |||
| try { | |||
| //有价券支付成功 | |||
| if (status.equals(EnumPayStatus.PAY_STATUS_SUCCESS.getCode())) { | |||
| // 前端提示支付成功, 不作为支付成功标志,只检查支付订单状态 | |||
| // 有价券不走update, callback更新 | |||
| if (payOrderId<=0) { | |||
| logger.error("/api/pay/updatePayOrder error : payOrderId不能为空: " + paramMap.toString()); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "payOrderId非法"+payOrderId+"[payOrderIdStr:"+payOrderIdStr+"]"); | |||
| } | |||
| payOrder = wxPayOrderService.getById(payOrderId,payOrder.getTenantId()); | |||
| if (null == payOrder) { | |||
| return new ResultData(ErrorCode.PAY_ORDER_ERROR, "未查询到payOrder."); | |||
| } | |||
| WxOrder order = wxOrderService.getById(orderId,payOrder.getTenantId()); | |||
| if (null == order) { | |||
| return new ResultData(ErrorCode.PAY_ORDER_ERROR, "未查询到Order["+orderId+"]."); | |||
| } | |||
| WxCoupon wxCoupon = wxCouponService.getById(order.getProductId(),order.getTenantId()); | |||
| if (null == wxCoupon) { | |||
| return new ResultData(ErrorCode.PAY_ORDER_ERROR, "未查询到优惠券[orderId:"+orderId+"]."); | |||
| } | |||
| //拼团的订单,如果查询到是拼团待付款的,则重新查询是否已经真的支付,其他的直接返回订单信息 | |||
| if (wxPayOrderService.isOrderGroupCoupon(payOrder, wxCoupon)) { | |||
| if (!order.getOrderStatus().equals(EnumOrderStatus.ORDER_STATUS_COOPERATING_UNPAID.getCode())) { | |||
| return new ResultData(Result.SUCCESS, "支付状态更新成功", order); | |||
| } | |||
| }else { | |||
| //非拼团的订单,支付成功,关闭订单,撤销支付订单,支付转退款的,直接返回订单信息,其他需要查询真实支付状态 | |||
| if (payOrder.getPayOrderStatus().equals(EnumPayStatus.PAY_STATUS_SUCCESS.getCode())|| | |||
| payOrder.getPayOrderStatus().equals(EnumPayStatus.PAY_STATUS_CLOSE.getCode())|| | |||
| payOrder.getPayOrderStatus().equals(EnumPayStatus.PAY_STATUS_REVERSE.getCode())|| | |||
| payOrder.getPayOrderStatus().equals(EnumPayStatus.PAY_STATUS_REFUND.getCode())) { | |||
| return new ResultData(Result.SUCCESS, "支付状态更新成功", order); | |||
| } | |||
| } | |||
| //查询微信订单状态并更新 | |||
| WxAppinfo appInfo = wxAppinfoService.getCAppInfo(payOrder, EnumPayWay.getEnum(payOrder.getPayVendor())); | |||
| //WxCUser user = getUser(); | |||
| //WxAppinfo appInfo = getAppInfo(user.getAppId()); | |||
| if (null == appInfo) { | |||
| return new ResultData(ErrorCode.PAY_ORDER_ERROR, "当前支付类型["+payOrder.getPayVendor()+"]找不到C端appInfo"); | |||
| } | |||
| WxPayAccount payAccount = wxPayAccountService.getById(appInfo.getPayId()); | |||
| try { | |||
| WxPayOrder wo = wxPayOrderService.handleWxOrderQuery(payOrder, order, appInfo, payAccount, IdWorker.get(),false); | |||
| if (null != wo) { | |||
| return new ResultData(Result.SUCCESS, "支付状态更新成功", order); | |||
| } | |||
| }catch(MallinkException e) { | |||
| //已经同步了微信的支付状态,表示已经更新 | |||
| return new ResultData(Result.SUCCESS, "支付状态更新成功", order); | |||
| } | |||
| return new ResultData(ErrorCode.PAY_ORDER_ERROR, "查询微信订单支付状态失败,请稍后!"); | |||
| } else if (status.equals(EnumPayStatus.PAY_STATUS_FAIL.getCode())) { | |||
| // 有价券支付失败 | |||
| wxPayOrderService.handlePayOrderFail(payOrder, EnumPayStatus.PAY_STATUS_FAIL.getCode()); | |||
| } | |||
| return new ResultData(Result.SUCCESS, "支付状态更新成功"); | |||
| } catch (MallinkException e) { | |||
| logger.error("支付状态更新失败2: " + payOrder.toString() + ", e:" + e.getMessage()); | |||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||
| } catch (Exception e) { | |||
| logger.error("支付状态更新失败3: " + payOrder.toString() + ", e:" + e.getMessage()); | |||
| return new ResultData(ErrorCode.PAY_ORDER_ERROR, "支付状态更新失败3: " + payOrder.toString() + ", e:" + e.getMessage()); | |||
| } | |||
| } | |||
| } | |||
| @@ -13,10 +13,12 @@ public interface VideoExcutor { | |||
| */ | |||
| public VideUploadResult uploadLocalVideo(String title,String localFile); | |||
| public VideUploadResult uploadLocalVideo(String title,InputStream inputStream); | |||
| public VideUploadResult uploadLocalVideo(String title,InputStream inputStream,String fileFormat); | |||
| //ext,后缀名 | |||
| public VideUploadResult uploadNetVideo(String title,String url,String ext); | |||
| public String getVedioUploadProgress(String videoId); | |||
| VideUploadResult getVideoDetail(String videoId); | |||
| } | |||
| @@ -1,11 +1,11 @@ | |||
| package com.iformall.video.aliyun; | |||
| import java.io.File; | |||
| import java.io.FileInputStream; | |||
| import java.io.FileNotFoundException; | |||
| import java.io.IOException; | |||
| import java.io.InputStream; | |||
| import java.util.List; | |||
| import java.util.UUID; | |||
| import com.aliyuncs.vod.model.v20170321.GetPlayInfoResponse; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.beans.factory.annotation.Qualifier; | |||
| import org.springframework.data.redis.core.RedisTemplate; | |||
| @@ -65,14 +65,32 @@ public class AliyunVideoExcutor implements VideoExcutor { | |||
| return result; | |||
| } | |||
| private void setVideUploadResult(VideUploadResult result,String videoId) throws ClientException { | |||
| result.setVideoId(videoId); | |||
| GetPlayInfoResponse response = AliyunVedioServer.getPlayInfoResponse(config, videoId); | |||
| if(response != null){ | |||
| List<GetPlayInfoResponse.PlayInfo> playInfoList = response.getPlayInfoList(); | |||
| //播放地址 | |||
| for (GetPlayInfoResponse.PlayInfo playInfo : playInfoList) { | |||
| result.setVideoUrl(playInfo.getPlayURL()); | |||
| break; | |||
| } | |||
| GetPlayInfoResponse.VideoBase videoBase = response.getVideoBase(); | |||
| result.setDuration(videoBase.getDuration()); | |||
| result.setCoverURL(videoBase.getCoverURL()); | |||
| result.setTitle(videoBase.getTitle()); | |||
| } | |||
| } | |||
| @Override | |||
| public VideUploadResult uploadLocalVideo(String title,InputStream inputStream) { | |||
| public VideUploadResult uploadLocalVideo(String title,InputStream inputStream,String fileFormat) { | |||
| VideUploadResult result = new VideUploadResult(); | |||
| UploadStreamResponse response; | |||
| try { | |||
| response = AliyunVedioUpload.uploadStream(config.getAccessKeyId(), config.getAccessKeySecret(),config.getRegionId(), title, "", inputStream,redisTemplate); | |||
| response = AliyunVedioUpload.uploadStream(config.getAccessKeyId(), config.getAccessKeySecret(),config.getRegionId(), title, UUID.randomUUID().toString().replace("-","")+fileFormat, inputStream,redisTemplate); | |||
| if (response.isSuccess()) { | |||
| result.setVideoId(response.getVideoId()); | |||
| // setVideUploadResult(result,response.getVideoId()); | |||
| result.setVideoUrl(getUrlByVeidoId(response.getVideoId())); | |||
| result.setSuccess(true); | |||
| } else { //如果设置回调URL无效,不影响视频上传,可以返回VideoId同时会返回错误码。其他情况上传失败时,VideoId为空,此时需要根据返回错误码分析具体错误原因 | |||
| @@ -114,4 +132,33 @@ public class AliyunVideoExcutor implements VideoExcutor { | |||
| public String getVedioUploadProgress(String videoId) { | |||
| return AliyunVedioUpload.getUploadProgress(redisTemplate, videoId); | |||
| } | |||
| @Override | |||
| public VideUploadResult getVideoDetail(String videoId) { | |||
| VideUploadResult result = new VideUploadResult(); | |||
| result.setVideoId(videoId); | |||
| try { | |||
| GetPlayInfoResponse response = AliyunVedioServer.getPlayInfoResponse(config, videoId); | |||
| if(response != null){ | |||
| List<GetPlayInfoResponse.PlayInfo> playInfoList = response.getPlayInfoList(); | |||
| //播放地址 | |||
| for (GetPlayInfoResponse.PlayInfo playInfo : playInfoList) { | |||
| result.setVideoUrl(playInfo.getPlayURL()); | |||
| break; | |||
| } | |||
| GetPlayInfoResponse.VideoBase videoBase = response.getVideoBase(); | |||
| result.setDuration(videoBase.getDuration()); | |||
| result.setCoverURL(videoBase.getCoverURL()); | |||
| result.setTitle(videoBase.getTitle()); | |||
| result.setSuccess(true); | |||
| }else{ | |||
| result.setSuccess(false); | |||
| result.setMsg("未获取到视频"); | |||
| } | |||
| } catch (ClientException e) { | |||
| result.setSuccess(false); | |||
| result.setMsg("获取视频请求异常"); | |||
| } | |||
| return result; | |||
| } | |||
| } | |||
| @@ -41,4 +41,17 @@ public class AliyunVedioServer { | |||
| } | |||
| return null; | |||
| } | |||
| public static GetPlayInfoResponse getPlayInfoResponse(AliyunVideoConfig config, String videoId) throws ClientException { | |||
| DefaultAcsClient client = initVodClient(config); | |||
| GetPlayInfoResponse response = new GetPlayInfoResponse(); | |||
| try { | |||
| GetPlayInfoRequest request = new GetPlayInfoRequest(); | |||
| request.setVideoId(videoId); | |||
| return client.getAcsResponse(request); | |||
| } catch (Exception e) { | |||
| log.error("getVedioUrl error.",e); | |||
| } | |||
| return null; | |||
| } | |||
| } | |||
| @@ -350,15 +350,15 @@ public class AliyunVedioUpload { | |||
| /* 存储区域(可选) */ | |||
| //request.setStorageLocation("in-201703232118266-5sejdln9o.oss-cn-shanghai.aliyuncs.com"); | |||
| /* 开启默认上传进度回调 */ | |||
| request.setPrintProgress(true); | |||
| // request.setPrintProgress(true); | |||
| /* 设置自定义上传进度回调 (必须继承 VoDProgressListener) */ | |||
| request.setProgressListener(new PutObjectProgressListener()); | |||
| // request.setProgressListener(new PutObjectProgressListener()); | |||
| /* 设置应用ID*/ | |||
| //request.setAppId("app-1000000"); | |||
| /* 点播服务接入点 */ | |||
| request.setApiRegionId(regionId); | |||
| /* ECS部署区域*/ | |||
| request.setEcsRegionId(regionId); | |||
| // request.setEcsRegionId(regionId); | |||
| UploadVideoImpl uploader = new UploadVideoImpl(); | |||
| UploadStreamResponse response = uploader.uploadStream(request); | |||
| return response; | |||
| @@ -6,6 +6,9 @@ import lombok.Data; | |||
| public class VideUploadResult { | |||
| private String videoId; | |||
| private String videoUrl; | |||
| private String coverURL;//视频封面 | |||
| private String duration;//视频时长 | |||
| private String title;//视频标题 | |||
| private boolean success = false; | |||
| private String msg; | |||
| } | |||