| @@ -2,10 +2,12 @@ package com.iformall.controller; | |||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.WxCUser; | |||||
| import com.iformall.domain.po.WxCUserBasicInfo; | import com.iformall.domain.po.WxCUserBasicInfo; | ||||
| import com.iformall.domain.po.WxLevelConfig; | import com.iformall.domain.po.WxLevelConfig; | ||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.service.WxCUserBasicInfoService; | import com.iformall.service.WxCUserBasicInfoService; | ||||
| import com.iformall.service.WxCUserService; | |||||
| import com.iformall.service.WxLevelConfigService; | import com.iformall.service.WxLevelConfigService; | ||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| import io.swagger.annotations.ApiOperation; | import io.swagger.annotations.ApiOperation; | ||||
| @@ -26,6 +28,9 @@ public class UserBasicInfoController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||||
| @Autowired | |||||
| private WxCUserService wxCUserService; | |||||
| @Autowired | @Autowired | ||||
| private WxCUserBasicInfoService wxCUserBasicInfoService; | private WxCUserBasicInfoService wxCUserBasicInfoService; | ||||
| @@ -42,6 +47,9 @@ public class UserBasicInfoController extends BaseController { | |||||
| public ResultData userRegister(@RequestBody Map<String,Object> map) { | public ResultData userRegister(@RequestBody Map<String,Object> map) { | ||||
| logger.info("UserBasicInfoController >>>>>>>>>>>> userRegister >>>>>>>>>>>>>"+map.toString()); | logger.info("UserBasicInfoController >>>>>>>>>>>> userRegister >>>>>>>>>>>>>"+map.toString()); | ||||
| String phone = (String) map.get("phone"); | String phone = (String) map.get("phone"); | ||||
| String nickName = (String) map.get("nickName"); | |||||
| String sexStr = (String) map.get("sex"); | |||||
| String avatarUrl = (String) map.get("avatarUrl"); | |||||
| if(StringUtils.isBlank(phone)){ | if(StringUtils.isBlank(phone)){ | ||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"手机号不能为空"); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"手机号不能为空"); | ||||
| } | } | ||||
| @@ -49,22 +57,71 @@ public class UserBasicInfoController extends BaseController { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"手机号格式不正确"); | return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"手机号格式不正确"); | ||||
| } | } | ||||
| Integer sex = 0; | |||||
| if(StringUtils.isNotBlank(sexStr)){ | |||||
| try { | |||||
| sex = Integer.parseInt(sexStr); | |||||
| } catch (NumberFormatException e) { | |||||
| // e.printStackTrace(); | |||||
| } | |||||
| } | |||||
| TenantEntity tenantEntity = getTenantInfo(); | TenantEntity tenantEntity = getTenantInfo(); | ||||
| WxCUserBasicInfo userBasicInfo = wxCUserBasicInfoService.registerByPhone(tenantEntity, phone); | |||||
| WxCUserBasicInfo userBasicInfo = wxCUserBasicInfoService.registerByPhone(tenantEntity, phone,nickName,sex,avatarUrl); | |||||
| this.setLevel(userBasicInfo,tenantEntity); | |||||
| return new ResultData(userBasicInfo); | |||||
| } | |||||
| /** | |||||
| * | |||||
| * @param | |||||
| * @return | |||||
| */ | |||||
| @PostMapping("/get") | |||||
| @ApiOperation(value = "会员", notes = "") | |||||
| public ResultData getUserInfo(@RequestBody Map<String,Object> map) { | |||||
| logger.info("UserBasicInfoController >>>>>>>>>>>> getUserInfo >>>>>>>>>>>>>"+map.toString()); | |||||
| String phone = (String) map.get("phone"); | |||||
| String openId = (String) map.get("openId"); | |||||
| WxCUserBasicInfo basicInfo = null; | |||||
| if(StringUtils.isBlank(phone) && StringUtils.isBlank(openId)){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
| } | |||||
| if(StringUtils.isNotBlank(phone)){ | |||||
| basicInfo = wxCUserBasicInfoService.findInfoByPhone(getTenantInfo(), phone); | |||||
| } | |||||
| if(basicInfo == null && StringUtils.isNotBlank(openId)){ | |||||
| WxCUser wxCUserQ = new WxCUser(); | |||||
| wxCUserQ.updateTenantInfo(getTenantInfo()); | |||||
| wxCUserQ.setOpenId(openId); | |||||
| WxCUser byOpenId = wxCUserService.getByOpenId(wxCUserQ); | |||||
| if(byOpenId != null && byOpenId.basicInfoIs()){ | |||||
| basicInfo = wxCUserBasicInfoService.getById(byOpenId.getUserId(),getTenantInfo().getFinalTenantId()); | |||||
| } | |||||
| } | |||||
| if(basicInfo == null){ | |||||
| return new ResultData(ErrorCode.USER_IS_EMPTY); | |||||
| } | |||||
| this.setLevel(basicInfo,getTenantInfo()); | |||||
| return new ResultData(basicInfo); | |||||
| } | |||||
| private void setLevel(WxCUserBasicInfo basicInfo,TenantEntity tenantEntity){ | |||||
| List<WxLevelConfig> levelList = wxLevelConfigService.getByTenantInfo(tenantEntity); | List<WxLevelConfig> levelList = wxLevelConfigService.getByTenantInfo(tenantEntity); | ||||
| userBasicInfo.setLevelList(levelList); | |||||
| userBasicInfo.setLevel(WxLevelConfigService.DEFAULT_LEVEL); | |||||
| if(userBasicInfo.getPoins() != null && userBasicInfo.getPoins() > 0){ | |||||
| basicInfo.setLevelList(levelList); | |||||
| basicInfo.setLevel(WxLevelConfigService.DEFAULT_LEVEL); | |||||
| if(basicInfo.getPoins() != null && basicInfo.getPoins() > 0){ | |||||
| for (WxLevelConfig levelConfig : levelList) { | for (WxLevelConfig levelConfig : levelList) { | ||||
| if (userBasicInfo.getPoins() >= levelConfig.getPoints()) { | |||||
| userBasicInfo.setLevel(levelConfig.getLevel()); | |||||
| if (basicInfo.getPoins() >= levelConfig.getPoints()) { | |||||
| basicInfo.setLevel(levelConfig.getLevel()); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| return new ResultData(userBasicInfo); | |||||
| } | } | ||||
| } | } | ||||
| @@ -195,6 +195,11 @@ public enum ErrorCode{ | |||||
| ORDER_PRESS_IS_OVERTIME(3010, "砍价已过期"), | ORDER_PRESS_IS_OVERTIME(3010, "砍价已过期"), | ||||
| ORDER_PRESS_IS_COMPLETE(3011, "砍价已完成"), | ORDER_PRESS_IS_COMPLETE(3011, "砍价已完成"), | ||||
| ORDER_UNPAID(3012, "您有未支付的订单"), | ORDER_UNPAID(3012, "您有未支付的订单"), | ||||
| ORDER_IS_FIND(3013, "订单已存在"), | |||||
| ORDER_PAY_IN_REFUND(3014, "订单待退款"), | |||||
| ORDER_PAY_REFUND(3015, "订单已退款"), | |||||
| ORDER_PAY_REFUND_FAIL(3016, "订单退款失败"), | |||||
| ORDER_PAY_EVALUATE(3017, "订单已评价"), | |||||
| ORDER_USER_NOT_MATCH(2013, "订单用户不匹配"), | ORDER_USER_NOT_MATCH(2013, "订单用户不匹配"), | ||||
| ORDER_COUPON_CHANNEL_NOT_MATCH(2014, "订单渠道不匹配"), | ORDER_COUPON_CHANNEL_NOT_MATCH(2014, "订单渠道不匹配"), | ||||
| ORDER_COUPON_NOT_MATCH(2015, "订单券不匹配"), | ORDER_COUPON_NOT_MATCH(2015, "订单券不匹配"), | ||||
| @@ -609,6 +614,12 @@ public enum ErrorCode{ | |||||
| GOOAGOO_OPEN_FAIL(62002,"数衍信息请求失败"), | GOOAGOO_OPEN_FAIL(62002,"数衍信息请求失败"), | ||||
| /** | |||||
| * tt | |||||
| */ | |||||
| TTCOUPON_IS_EMPTY(63000, "课程不存在"), | |||||
| TTCOUPON_IS_TAKE_OFF(63001, "课程不在上架状态"), | |||||
| ; | ; | ||||
| private int code; | private int code; | ||||
| @@ -4,6 +4,7 @@ import cn.afterturn.easypoi.excel.annotation.Excel; | |||||
| import com.baomidou.mybatisplus.annotation.TableField; | import com.baomidou.mybatisplus.annotation.TableField; | ||||
| import com.baomidou.mybatisplus.annotation.TableName; | import com.baomidou.mybatisplus.annotation.TableName; | ||||
| import com.iformall.common.SortColumn; | import com.iformall.common.SortColumn; | ||||
| import com.iformall.domain.po.WxMerchant; | |||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import lombok.Data; | import lombok.Data; | ||||
| import lombok.EqualsAndHashCode; | import lombok.EqualsAndHashCode; | ||||
| @@ -115,14 +116,22 @@ public class TtCoupon extends TenantEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value="作者",name="merchantId") | @io.swagger.annotations.ApiModelProperty(value="作者",name="merchantId") | ||||
| private Long merchantId; | private Long merchantId; | ||||
| @io.swagger.annotations.ApiModelProperty(value="",name="merchantName") | |||||
| @io.swagger.annotations.ApiModelProperty(value="",name="merchantName")//弃用 | |||||
| private String merchantName; | private String merchantName; | ||||
| @io.swagger.annotations.ApiModelProperty(value="",name="merchantPic")//弃用 | |||||
| private String merchantPic; | |||||
| @io.swagger.annotations.ApiModelProperty(value="业态",name="businessId") | @io.swagger.annotations.ApiModelProperty(value="业态",name="businessId") | ||||
| private Long businessId; | private Long businessId; | ||||
| @io.swagger.annotations.ApiModelProperty(value="",name="businessName") | @io.swagger.annotations.ApiModelProperty(value="",name="businessName") | ||||
| private String businessName; | private String businessName; | ||||
| @TableField(exist = false) | |||||
| private WxMerchant author; | |||||
| @TableField(exist = false) | |||||
| private TtCoupon couponCoumn; | |||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| @io.swagger.annotations.ApiModelProperty(value = "审批流参数", name = "columnCoupons") | @io.swagger.annotations.ApiModelProperty(value = "审批流参数", name = "columnCoupons") | ||||
| private List<TtCoupon> columnCoupons; | private List<TtCoupon> columnCoupons; | ||||
| @@ -0,0 +1,84 @@ | |||||
| package com.iformall.domain.po.tt; | |||||
| import cn.afterturn.easypoi.excel.annotation.Excel; | |||||
| import com.baomidou.mybatisplus.annotation.TableField; | |||||
| import com.baomidou.mybatisplus.annotation.TableName; | |||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import lombok.Data; | |||||
| import lombok.EqualsAndHashCode; | |||||
| import lombok.ToString; | |||||
| import java.math.BigDecimal; | |||||
| import java.util.Date; | |||||
| import java.util.List; | |||||
| @TableName(value = "tt_order") | |||||
| @Data | |||||
| @ToString(callSuper = true) | |||||
| @EqualsAndHashCode(callSuper = true) | |||||
| public class TtOrder extends TenantEntity { | |||||
| protected Long id; | |||||
| @io.swagger.annotations.ApiModelProperty(value="c端用户id",name="cUserId") | |||||
| private Long cUserId; | |||||
| @TableField(exist = false) | |||||
| private String nickName; | |||||
| @TableField(exist = false) | |||||
| private String phone; | |||||
| @io.swagger.annotations.ApiModelProperty(value="产品ID(couponId)",name="productId") | |||||
| private Long productId; | |||||
| @TableField(exist = false) | |||||
| private String productTitle; | |||||
| @TableField(exist = false) | |||||
| private String productPic; | |||||
| @TableField(exist = false) | |||||
| private Long authorId; | |||||
| @TableField(exist = false) | |||||
| private String author; | |||||
| @TableField(exist = false) | |||||
| private String authorPic; | |||||
| @io.swagger.annotations.ApiModelProperty(value="支付类型(1:微信,)",name="type") | |||||
| private Integer type; | |||||
| @io.swagger.annotations.ApiModelProperty(value="0: 付款 1: 退款",name="paymentType") | |||||
| private Integer paymentType; | |||||
| @io.swagger.annotations.ApiModelProperty(value="支付金额(分):允许有负数,退款时为负值。",name="payment") | |||||
| private Integer payment; | |||||
| @io.swagger.annotations.ApiModelProperty(value="支付时间",name="paymentTime") | |||||
| private Date paymentTime; | |||||
| @Excel(name = "订单状态", width = 20, orderNum = "9", replace = {"待付款_0", "已支付_1", "已取消_2", "待退款_3", "已退款_4", "退款失败_5", " _-1"}) | |||||
| @io.swagger.annotations.ApiModelProperty(value="\"待付款_0\", \"已支付_1\", \"已取消_2\", \"待退款_3\", \"已退款_4\", \"退款失败_5\", \" _-1\"",name="orderStatus") | |||||
| private Integer orderStatus; | |||||
| @Excel(name = "订单日期", width = 20, orderNum = "7", format = "yyyy-MM-dd") | |||||
| @io.swagger.annotations.ApiModelProperty(value="创建时间/砍价开始时间",name="createDate") | |||||
| private Date createDate; | |||||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") | |||||
| private Date updateDate; | |||||
| public String getPaymentStr() { | |||||
| return payment != null ? new BigDecimal(payment).divide(new BigDecimal(100)).toPlainString() : paymentStr; | |||||
| } | |||||
| @Excel(name = "订单金额(元)", width = 20, orderNum = "6") | |||||
| @TableField(exist = false) | |||||
| private String paymentStr; | |||||
| @TableField(exist = false) | |||||
| protected TtCoupon ttCoupon; | |||||
| @TableField(exist = false) | |||||
| protected List<Integer> statusS; | |||||
| @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; | |||||
| } | |||||
| @@ -10,6 +10,7 @@ public enum EnumPayWay { | |||||
| PAY_WAY_WECHAT_WAP(2, "微信H5",EnumPayWayType.WX_H5PAY,EnumAppPlat.WX,null), | PAY_WAY_WECHAT_WAP(2, "微信H5",EnumPayWayType.WX_H5PAY,EnumAppPlat.WX,null), | ||||
| PAY_WAY_ALIPAY(3, "支付宝",EnumPayWayType.ALI_MINIPAY,EnumAppPlat.ALI,null), | PAY_WAY_ALIPAY(3, "支付宝",EnumPayWayType.ALI_MINIPAY,EnumAppPlat.ALI,null), | ||||
| PAY_WAY_ALIPAY_WAP(4, "支付宝H5",EnumPayWayType.ALI_H5PAY,EnumAppPlat.ALI,null), | PAY_WAY_ALIPAY_WAP(4, "支付宝H5",EnumPayWayType.ALI_H5PAY,EnumAppPlat.ALI,null), | ||||
| PAY_WAY_TT(5, "抖音担保支付",EnumPayWayType.TT_PAY,EnumAppPlat.TOUTIAO,null), | |||||
| PAY_WAY_POS_B(10, "POS B端",EnumPayWayType.POS,null,null), | PAY_WAY_POS_B(10, "POS B端",EnumPayWayType.POS,null,null), | ||||
| PAY_WAY_POS_NEU(11, "POS 东软",EnumPayWayType.NEU_POS,null,EnumCardSpendFrom.POS), | 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_MERCHANT(91, "商户注券,无需支付",null,null,null), | ||||
| @@ -71,6 +72,6 @@ public enum EnumPayWay { | |||||
| public static enum EnumPayWayType { | public static enum EnumPayWayType { | ||||
| WX_MINIPAY,WX_H5PAY,ALI_MINIPAY,ALI_H5PAY,NEU_POS,POS | |||||
| WX_MINIPAY,WX_H5PAY,ALI_MINIPAY,ALI_H5PAY,TT_PAY,NEU_POS,POS | |||||
| } | } | ||||
| } | } | ||||
| @@ -0,0 +1,41 @@ | |||||
| package com.iformall.enums; | |||||
| /** | |||||
| * Created by Stormeye on 2018/08/09. | |||||
| */ | |||||
| public enum EnumTtCouponStatus { | |||||
| TTCOUPON_STATUS_DRAFT(1, "草稿"), | |||||
| TTCOUPON_STATUS_EXAMINE(2, "审核中"), | |||||
| TTCOUPON_STATUS_REJECT(3, "已驳回"), | |||||
| TTCOUPON_STATUS_BEFOR_SHELF(4, "待上架"), | |||||
| TTCOUPON_STATUS_SHELFING(5, "已上架"), | |||||
| TTCOUPON_STATUS_AFTER_SHELF(6, "已下架"), | |||||
| ; | |||||
| public static EnumTtCouponStatus getEnum(Integer code) { | |||||
| for (EnumTtCouponStatus value : values()) { | |||||
| if (value.getCode().equals(code)) { | |||||
| return value; | |||||
| } | |||||
| } | |||||
| return null; | |||||
| } | |||||
| private Integer code; | |||||
| private String message; | |||||
| EnumTtCouponStatus(Integer code, String message) { | |||||
| this.code = code; | |||||
| this.message = message; | |||||
| } | |||||
| public Integer getCode() { | |||||
| return code; | |||||
| } | |||||
| public String getMessage() { | |||||
| return message; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,38 @@ | |||||
| package com.iformall.enums; | |||||
| /** | |||||
| * Created by Stormeye on 2018/08/09. | |||||
| */ | |||||
| public enum EnumTtCouponType { | |||||
| COUPON_COLUMN(1, "专栏"), | |||||
| COUPON_SINGLE(2, "单课程"), | |||||
| COUPON_MORE(3, "子课程"), | |||||
| ; | |||||
| public static EnumTtCouponType getEnum(Integer code) { | |||||
| for (EnumTtCouponType value : values()) { | |||||
| if (value.getCode().equals(code)) { | |||||
| return value; | |||||
| } | |||||
| } | |||||
| return null; | |||||
| } | |||||
| private Integer code; | |||||
| private String message; | |||||
| EnumTtCouponType(Integer code, String message) { | |||||
| this.code = code; | |||||
| this.message = message; | |||||
| } | |||||
| public Integer getCode() { | |||||
| return code; | |||||
| } | |||||
| public String getMessage() { | |||||
| return message; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,20 @@ | |||||
| package com.iformall.mapper; | |||||
| import com.iformall.common.CommonMapper; | |||||
| import com.iformall.domain.dto.WxOrderReportDto; | |||||
| import com.iformall.domain.po.WxOrder; | |||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import com.iformall.domain.po.tt.TtOrder; | |||||
| import com.iformall.domain.vo.*; | |||||
| import org.apache.ibatis.annotations.Param; | |||||
| import java.util.HashMap; | |||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| public interface TtOrderMapper extends CommonMapper<TtOrder, Long> { | |||||
| List<TtOrder> findList(TtOrder record); | |||||
| Integer findListCount(TtOrder orderQ); | |||||
| } | |||||
| @@ -175,7 +175,7 @@ public interface WxCUserBasicInfoService { | |||||
| void updateQrCode(WxCUserBasicInfo wxCUserBasicInfo); | void updateQrCode(WxCUserBasicInfo wxCUserBasicInfo); | ||||
| WxCUserBasicInfo registerByPhone(TenantEntity tenantEntity, String phone); | |||||
| WxCUserBasicInfo registerByPhone(TenantEntity tenantEntity, String phone, String nickName, Integer sex, String avatarUrl); | |||||
| int addCredit(Long userId, TenantEntity tenantInfo, EnumScoreType wechatPhone); | int addCredit(Long userId, TenantEntity tenantInfo, EnumScoreType wechatPhone); | ||||
| } | } | ||||
| @@ -117,7 +117,7 @@ public class AliBusinessCircleOrderServiceImpl implements AliBusinessCircleOrder | |||||
| AliPayCUser aliUser = aliPayCUserService.getByAliPayUserId(userQ); | AliPayCUser aliUser = aliPayCUserService.getByAliPayUserId(userQ); | ||||
| if(aliUser != null){ | if(aliUser != null){ | ||||
| // WxCUserBasicInfo infoByPhone = wxCUserBasicInfoService.findInfoByPhone(aliUser, aliUser.getPhone()); | // WxCUserBasicInfo infoByPhone = wxCUserBasicInfoService.findInfoByPhone(aliUser, aliUser.getPhone()); | ||||
| WxCUserBasicInfo infoByPhone = wxCUserBasicInfoService.registerByPhone(aliUser, aliUser.getPhone()); | |||||
| WxCUserBasicInfo infoByPhone = wxCUserBasicInfoService.registerByPhone(aliUser, aliUser.getPhone(),aliUser.getName(),null,null); | |||||
| if(infoByPhone != null ){ | if(infoByPhone != null ){ | ||||
| record.setCUserId(infoByPhone.getId()); | record.setCUserId(infoByPhone.getId()); | ||||
| }else{ | }else{ | ||||
| @@ -638,7 +638,7 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService,IExc | |||||
| } | } | ||||
| @Override | @Override | ||||
| public WxCUserBasicInfo registerByPhone(TenantEntity tenantEntity, String phone) { | |||||
| public WxCUserBasicInfo registerByPhone(TenantEntity tenantEntity, String phone, String nickName, Integer sex, String avatarUrl) { | |||||
| if (StringUtils.isBlank(phone)) | if (StringUtils.isBlank(phone)) | ||||
| return null; | return null; | ||||
| @@ -648,7 +648,21 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService,IExc | |||||
| basicInfo.setTenantId("," + tenantEntity.getTenantId() + ","); | basicInfo.setTenantId("," + tenantEntity.getTenantId() + ","); | ||||
| basicInfo.setFinalTenantId(tenantEntity.getFinalTenantId()); | basicInfo.setFinalTenantId(tenantEntity.getFinalTenantId()); | ||||
| basicInfo.setPhone(phone); | basicInfo.setPhone(phone); | ||||
| basicInfo.setNickName(nickName); | |||||
| basicInfo.setSex(sex); | |||||
| basicInfo.setAvatarUrl(avatarUrl); | |||||
| this.save(basicInfo); | this.save(basicInfo); | ||||
| }else{ | |||||
| if(StringUtils.isNotBlank(nickName)){ | |||||
| basicInfo.setNickName(nickName); | |||||
| } | |||||
| if(sex != null){ | |||||
| basicInfo.setSex(sex); | |||||
| } | |||||
| if(StringUtils.isNotBlank(avatarUrl)){ | |||||
| basicInfo.setAvatarUrl(avatarUrl); | |||||
| } | |||||
| wxCUserBasicInfoMapper.updateById(basicInfo); | |||||
| } | } | ||||
| return basicInfo; | return basicInfo; | ||||
| @@ -131,7 +131,7 @@ public class WxThirdPartyOrdersServiceImpl implements WxThirdPartyOrdersService | |||||
| basicInfo = wxCUserBasicInfoService.getById(userId, record.getFinalTenantId()); | basicInfo = wxCUserBasicInfoService.getById(userId, record.getFinalTenantId()); | ||||
| } | } | ||||
| if(basicInfo == null){ | if(basicInfo == null){ | ||||
| basicInfo = wxCUserBasicInfoService.registerByPhone(record, record.getUserPhone()); | |||||
| basicInfo = wxCUserBasicInfoService.registerByPhone(record, record.getUserPhone(),null,null,null); | |||||
| } | } | ||||
| if(basicInfo != null){ | if(basicInfo != null){ | ||||
| @@ -38,4 +38,5 @@ public interface TtCouponService { | |||||
| */ | */ | ||||
| void deleteById(Long id); | void deleteById(Long id); | ||||
| TtCoupon detail(Long productId); | |||||
| } | } | ||||
| @@ -0,0 +1,27 @@ | |||||
| 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.base.TenantEntity; | |||||
| import com.iformall.domain.po.tt.TtOrder; | |||||
| import com.iformall.enums.EnumPayWay; | |||||
| public interface TtOrderService { | |||||
| /** | |||||
| * 根据实体查询分页列表 | |||||
| * | |||||
| * @param record | |||||
| * @param pageIndex | |||||
| * @param pageSize | |||||
| * @return | |||||
| */ | |||||
| PageInfo<TtOrder> listAsPage(TtOrder record, Integer pageIndex, Integer pageSize); | |||||
| ResultData saveOrder(Long couponId, Long memberId, EnumPayWay payWay, TenantEntity tenantInfo); | |||||
| ResultData cancelOrder(Long orderId, Long memberId); | |||||
| TtOrder detail(Long orderId, Long memberId); | |||||
| } | |||||
| @@ -7,6 +7,7 @@ import com.iformall.common.IdWorker; | |||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.tt.TtCoupon; | import com.iformall.domain.po.tt.TtCoupon; | ||||
| import com.iformall.mapper.*; | import com.iformall.mapper.*; | ||||
| import com.iformall.service.WxMerchantService; | |||||
| import com.iformall.service.tt.TtCouponService; | import com.iformall.service.tt.TtCouponService; | ||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| @@ -26,6 +27,9 @@ public class TtCouponServiceImpl implements TtCouponService { | |||||
| @Autowired | @Autowired | ||||
| TtCouponMapper ttCouponMapper; | TtCouponMapper ttCouponMapper; | ||||
| @Autowired | |||||
| WxMerchantService wxMerchantService; | |||||
| @Override | @Override | ||||
| public PageInfo<TtCoupon> listAsPage(TtCoupon record, Integer pageIndex, Integer pageSize) { | public PageInfo<TtCoupon> listAsPage(TtCoupon record, Integer pageIndex, Integer pageSize) { | ||||
| @@ -69,7 +73,6 @@ public class TtCouponServiceImpl implements TtCouponService { | |||||
| } else { | } else { | ||||
| record.setUpdateDate(new Date()); | record.setUpdateDate(new Date()); | ||||
| ttCouponMapper.updateById(record); | ttCouponMapper.updateById(record); | ||||
| } | } | ||||
| return new ResultData(record.getId()); | return new ResultData(record.getId()); | ||||
| } | } | ||||
| @@ -78,4 +81,11 @@ public class TtCouponServiceImpl implements TtCouponService { | |||||
| public void deleteById(Long id) { | public void deleteById(Long id) { | ||||
| ttCouponMapper.deleteById(id); | ttCouponMapper.deleteById(id); | ||||
| } | } | ||||
| @Override | |||||
| public TtCoupon detail(Long productId) { | |||||
| TtCoupon byId = this.getById(productId); | |||||
| byId.setAuthor(wxMerchantService.getById(byId.getMerchantId())); | |||||
| return byId; | |||||
| } | |||||
| } | } | ||||
| @@ -0,0 +1,156 @@ | |||||
| 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.*; | |||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import com.iformall.domain.po.tt.TtCoupon; | |||||
| import com.iformall.domain.po.tt.TtOrder; | |||||
| import com.iformall.enums.*; | |||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.mapper.*; | |||||
| import com.iformall.service.WxCUserBasicInfoService; | |||||
| import com.iformall.service.tt.TtCouponService; | |||||
| import com.iformall.service.tt.TtOrderService; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | |||||
| import java.util.*; | |||||
| @Service | |||||
| public class TtOrderServiceImpl implements TtOrderService { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private TtOrderMapper ttOrderMapper; | |||||
| @Autowired | |||||
| private TtCouponService ttCouponService; | |||||
| @Autowired | |||||
| private WxCUserBasicInfoService wxCUserBasicInfoService; | |||||
| @Override | |||||
| public PageInfo<TtOrder> listAsPage(TtOrder record, Integer pageIndex, Integer pageSize) { | |||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> ttOrderMapper.findList(record)); | |||||
| } | |||||
| @Override | |||||
| public ResultData saveOrder(Long couponId,Long cUserId,EnumPayWay payWay,TenantEntity tenantEntity) { | |||||
| logger.info("OrderSave: couponId:" + couponId + "---cUserId:"+cUserId); | |||||
| WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoService.getById(cUserId,tenantEntity.getFinalTenantId()); | |||||
| if(wxCUserBasicInfo == null){ | |||||
| return new ResultData(ErrorCode.USER_IS_EMPTY); | |||||
| } | |||||
| TtOrder orderQ = new TtOrder(); | |||||
| 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()); | |||||
| orderQ.setStatusS(statuss); | |||||
| Integer listCount = ttOrderMapper.findListCount(orderQ); | |||||
| if(listCount.intValue() > 0){ | |||||
| return new ResultData(ErrorCode.ORDER_IS_FIND); | |||||
| } | |||||
| if (wxCUserBasicInfo.getStatus().equals(EnumCUserBasicInfoStatus.LOCKED.getCode())) { | |||||
| logger.info("会员权益被锁定:cUserId:" + cUserId); | |||||
| return new ResultData(ErrorCode.MEMBER_IS_LOCKED); | |||||
| } | |||||
| TtCoupon coupon = ttCouponService.getById(couponId); | |||||
| if (null == coupon) { | |||||
| return new ResultData(ErrorCode.TTCOUPON_IS_EMPTY); | |||||
| } | |||||
| if (!coupon.getStatus().equals(EnumTtCouponStatus.TTCOUPON_STATUS_SHELFING.getCode())) { | |||||
| return new ResultData(ErrorCode.TTCOUPON_IS_TAKE_OFF); | |||||
| } | |||||
| try { | |||||
| // 4.2 保存订单 | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| Date now = new Date(); | |||||
| TtOrder order = new TtOrder(); | |||||
| order.setId(idWorker.nextId()); | |||||
| order.updateTenantInfo(tenantEntity); | |||||
| order.setCUserId(wxCUserBasicInfo.getId()); | |||||
| order.setProductId(coupon.getId()); | |||||
| order.setType(payWay.getCode()); | |||||
| 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.setPaymentTime(now); | |||||
| }else{ | |||||
| order.setOrderStatus(EnumOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode()); | |||||
| } | |||||
| order.setCreateDate(now); | |||||
| order.setUpdateDate(now); | |||||
| ttOrderMapper.insert(order); | |||||
| return new ResultData(order); | |||||
| } catch (MallinkException e) { | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(ErrorCode.ORDER_IS_FAIL, e.getMessage()); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public ResultData cancelOrder(Long orderId, Long memberId) { | |||||
| TtOrder ttOrder = ttOrderMapper.selectById(orderId); | |||||
| if(ttOrder == null){ | |||||
| return new ResultData(ErrorCode.ORDER_IS_NOT_FIND); | |||||
| } | |||||
| 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())){//订单待付款 | |||||
| TtOrder record = new TtOrder(); | |||||
| record.setId(ttOrder.getId()); | |||||
| record.setOrderStatus(EnumOrderStatus.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())){//订单已支付 | |||||
| return new ResultData(ErrorCode.ORDER_HAD_PAY); | |||||
| }else | |||||
| if(ttOrder.getOrderStatus().equals(EnumOrderStatus.ORDER_STATUS_OVERTIME_CANCEL.getCode())){//订单已取消 | |||||
| return new ResultData(ErrorCode.ORDER_HAD_CANCEL); | |||||
| }else | |||||
| if(ttOrder.getOrderStatus().equals(EnumOrderStatus.ORDER_STATUS_PENDING_REFUND.getCode())){//订单待退款 | |||||
| return new ResultData(ErrorCode.ORDER_PAY_IN_REFUND); | |||||
| }else | |||||
| if(ttOrder.getOrderStatus().equals(EnumOrderStatus.ORDER_STATUS_REFUND_SUCCESS.getCode())){//订单已退款 | |||||
| return new ResultData(ErrorCode.ORDER_PAY_REFUND); | |||||
| }else | |||||
| if(ttOrder.getOrderStatus().equals(EnumOrderStatus.ORDER_STATUS_REFUND_FAILD.getCode())){//订单退款失败 | |||||
| return new ResultData(ErrorCode.ORDER_PAY_REFUND_FAIL); | |||||
| } | |||||
| return new ResultData(ErrorCode.ORDER_IS_FAIL); | |||||
| } | |||||
| @Override | |||||
| public TtOrder detail(Long orderId, Long memberId) { | |||||
| TtOrder ttOrder = ttOrderMapper.selectById(orderId); | |||||
| if(ttOrder == null){ | |||||
| return null; | |||||
| } | |||||
| if(memberId != null && !ttOrder.getCUserId().equals(memberId)){ | |||||
| return null; | |||||
| } | |||||
| TtCoupon coupon = ttCouponService.detail(ttOrder.getProductId()); | |||||
| ttOrder.setTtCoupon(coupon); | |||||
| return ttOrder; | |||||
| } | |||||
| } | |||||
| @@ -37,6 +37,7 @@ | |||||
| <result column="popularity" jdbcType="INTEGER" property="popularity"/> | <result column="popularity" jdbcType="INTEGER" property="popularity"/> | ||||
| <result column="merchant_id" jdbcType="BIGINT" property="merchantId"/> | <result column="merchant_id" jdbcType="BIGINT" property="merchantId"/> | ||||
| <result column="merchant_name" jdbcType="VARCHAR" property="merchantName"/> | <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_id" jdbcType="BIGINT" property="businessId"/> | ||||
| <result column="business_name" jdbcType="VARCHAR" property="businessName"/> | <result column="business_name" jdbcType="VARCHAR" property="businessName"/> | ||||
| </resultMap> | </resultMap> | ||||
| @@ -47,7 +48,7 @@ | |||||
| `sale_price`, `orig_price`, `is_preview`, `preview_duration`, `detail`, `false_sell_count`, | `sale_price`, `orig_price`, `is_preview`, `preview_duration`, `detail`, `false_sell_count`, | ||||
| `dy_title`, `inventory`, `remark`, `status`, `create_date`, `update_date`, | `dy_title`, `inventory`, `remark`, `status`, `create_date`, `update_date`, | ||||
| `see_count`, `sell_count`, `assess_count`, `collect_count`, `is_del`, | `see_count`, `sell_count`, `assess_count`, `collect_count`, `is_del`, | ||||
| `column_id`, `popularity`, `merchant_id`, `merchant_name`, `business_id`, `business_name` | |||||
| `column_id`, `popularity`, `merchant_id`, `merchant_name`,`merchant_pic`, `business_id`, `business_name` | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||
| @@ -88,8 +89,11 @@ | |||||
| and `status` = #{status} | and `status` = #{status} | ||||
| </if> | </if> | ||||
| <if test=" null != startdate and null!=enddate"> | |||||
| and `create_date` between #{startdate} and #{enddate} | |||||
| <if test="startdate != null"> | |||||
| and `create_date` >= #{startdate} | |||||
| </if> | |||||
| <if test="enddate != null"> | |||||
| and `create_date` <= #{enddate} | |||||
| </if> | </if> | ||||
| <if test=" null != businessId "> | <if test=" null != businessId "> | ||||
| @@ -0,0 +1,152 @@ | |||||
| <?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.TtOrderMapper"> | |||||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.tt.TtOrder"> | |||||
| <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="c_user_id" jdbcType="BIGINT" property="cUserId"/> | |||||
| <result column="product_id" jdbcType="BIGINT" property="productId"/> | |||||
| <result column="type" jdbcType="TINYINT" property="type"/> | |||||
| <result column="payment_type" jdbcType="INTEGER" property="paymentType"/> | |||||
| <result column="payment" jdbcType="INTEGER" property="payment"/> | |||||
| <result column="payment_time" jdbcType="TIMESTAMP" property="paymentTime"/> | |||||
| <result column="order_status" jdbcType="INTEGER" property="orderStatus"/> | |||||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/> | |||||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/> | |||||
| <result column="nick_name" jdbcType="VARCHAR" property="nickName"/> | |||||
| <result column="phone" jdbcType="VARCHAR" property="phone"/> | |||||
| <result column="product_title" jdbcType="VARCHAR" property="productTitle"/> | |||||
| <result column="product_pic" jdbcType="VARCHAR" property="productPic"/> | |||||
| <result column="author" jdbcType="VARCHAR" property="author"/> | |||||
| <result column="author_pic" jdbcType="VARCHAR" property="authorPic"/> | |||||
| </resultMap> | |||||
| <sql id="allColumns"> | |||||
| o.`id`,o.`tenant_id`,o.`parent_tenant_id`,o.`c_user_id`,o.`product_id`,o.`type`,o.`payment_type`,o.`payment`, | |||||
| o.`payment_time`,o.`order_status`,o.`create_date`,o.`update_date`, | |||||
| u.`nick_name`,u.`phone`, | |||||
| c.`title` product_title,c.`coverImg` product_pic, | |||||
| m.`name` author,m.`imgUrl` author_pic | |||||
| </sql> | |||||
| <sql id="dynamicWhereConditions"> | |||||
| where 1 = 1 | |||||
| <if test=" null != id "> | |||||
| and o.`id` = #{id} | |||||
| </if> | |||||
| <if test=" null != tenantId and '' != tenantId"> | |||||
| and o.`tenant_id` = #{tenantId} | |||||
| </if> | |||||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||||
| and o.`parent_tenant_id` = #{parentTenantId} | |||||
| </if> | |||||
| <if test=" null != cUserId "> | |||||
| and o.`c_user_id` = #{cUserId} | |||||
| </if> | |||||
| <if test=" null != productId "> | |||||
| and o.`product_id` = #{productId} | |||||
| </if> | |||||
| <if test=" null != type "> | |||||
| and o.`type` = #{type} | |||||
| </if> | |||||
| <if test=" null != paymentType "> | |||||
| and o.`payment_type` = #{paymentType} | |||||
| </if> | |||||
| <if test="startdate != null"> | |||||
| and o.`payment_time` >= #{startdate} | |||||
| </if> | |||||
| <if test="enddate != null"> | |||||
| and o.`payment_time` <= #{enddate} | |||||
| </if> | |||||
| <if test=" null != orderStatus "> | |||||
| and o.`order_status` = #{orderStatus} | |||||
| </if> | |||||
| <if test=" null != nickName "> | |||||
| and u.`nick_name` like concat('%', #{nickName},'%') | |||||
| </if> | |||||
| <if test=" null != phone "> | |||||
| and u.`phone` like concat('%', #{phone},'%') | |||||
| </if> | |||||
| <if test=" null != productTitle "> | |||||
| and c.`title` like concat('%', #{productTitle},'%') | |||||
| </if> | |||||
| <if test=" null != authorId "> | |||||
| and c.merchant_id = #{authorId} | |||||
| </if> | |||||
| <if test=" null != author "> | |||||
| and m.`name` like concat('%', #{author},'%') | |||||
| </if> | |||||
| <if test=" null != statusS "> | |||||
| and o.`order_status` in | |||||
| <foreach collection="statusS" index="index" item="sItem" open="(" separator="," close=")"> | |||||
| #{sItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != ids "> | |||||
| and o.`id` in | |||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||||
| #{idItem} | |||||
| </foreach> | |||||
| </if> | |||||
| order by o.`update_date` desc | |||||
| </sql> | |||||
| <select id="findList" parameterType="com.iformall.domain.po.WxOrder" resultMap="BaseResultMap"> | |||||
| select | |||||
| <include refid="allColumns"/> | |||||
| from wx_order o | |||||
| left join tt_c_user u on o.c_user_id = u.id | |||||
| left join tt_coupon c on o.product_id = c.id | |||||
| left join wx_merchant m on c.merchant_id = m.id | |||||
| <include refid="dynamicWhereConditions"/> | |||||
| </select> | |||||
| <select id="findListCount" parameterType="com.iformall.domain.po.WxOrder" resultType="Integer"> | |||||
| select count(1) | |||||
| from wx_order | |||||
| where 1 = 1 | |||||
| <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 != cUserId "> | |||||
| and `c_user_id` = #{cUserId} | |||||
| </if> | |||||
| <if test=" null != productId "> | |||||
| and `product_id` = #{productId} | |||||
| </if> | |||||
| <if test=" null != orderStatus "> | |||||
| and `order_status` = #{orderStatus} | |||||
| </if> | |||||
| <if test=" null != statusS "> | |||||
| and `order_status` in | |||||
| <foreach collection="statusS" index="index" item="sItem" open="(" separator="," close=")"> | |||||
| #{sItem} | |||||
| </foreach> | |||||
| </if> | |||||
| </select> | |||||
| </mapper> | |||||
| @@ -269,7 +269,11 @@ | |||||
| <select id="findByOpenId" parameterType="com.iformall.domain.po.WxCUser" resultMap="BaseResultMap"> | <select id="findByOpenId" parameterType="com.iformall.domain.po.WxCUser" resultMap="BaseResultMap"> | ||||
| select <include refid="allColumns"/> from wx_c_user | select <include refid="allColumns"/> from wx_c_user | ||||
| where `app_id` = #{appId} and `open_id` = #{openId} | |||||
| where `open_id` = #{openId} | |||||
| <if test=" null != appId and '' != appId"> | |||||
| and `app_id` = #{appId} | |||||
| </if> | |||||
| </select> | </select> | ||||
| <select id="findByUnionId" parameterType="com.iformall.domain.po.WxCUser" resultMap="BaseResultMap"> | <select id="findByUnionId" parameterType="com.iformall.domain.po.WxCUser" resultMap="BaseResultMap"> | ||||
| @@ -232,6 +232,15 @@ public class BaseController { | |||||
| return member; | return member; | ||||
| } | } | ||||
| public Long getMemberId() { | |||||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | |||||
| Long memberId = (Long) request.getAttribute(Constant.LOGIN_MEMBER_KEY); | |||||
| if(memberId == null){ | |||||
| throw new MallinkException(ErrorCode.USER_IS_NOT_MEMBER); | |||||
| } | |||||
| return memberId; | |||||
| } | |||||
| public String getIpAddr() { | public String getIpAddr() { | ||||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | ||||
| String ipaddress = IPUtil.getIpAddr(request); | String ipaddress = IPUtil.getIpAddr(request); | ||||
| @@ -0,0 +1,167 @@ | |||||
| 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.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.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; | |||||
| 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.beans.factory.annotation.Qualifier; | |||||
| import org.springframework.data.redis.core.RedisTemplate; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import java.util.Date; | |||||
| import java.util.Map; | |||||
| @RestController | |||||
| @RequestMapping("/api/order/") | |||||
| @Api(description = "订单相关接口") | |||||
| public class TtOrderController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private TtOrderService ttOrderService; | |||||
| WxOrderService wxOrderService; | |||||
| @Autowired | |||||
| private WxCouponChannelService wxCouponChannelService; | |||||
| @Autowired | |||||
| private WxCouponService wxCouponService; | |||||
| @Autowired | |||||
| private WxCUserBasicInfoService wxCUserBasicInfoService; | |||||
| @Autowired | |||||
| @Qualifier("couponDetailRedisTemplate") | |||||
| RedisTemplate<String, WxCouponCVo> cdRedisTemplate; | |||||
| @Autowired | |||||
| RedisLock redisLock; | |||||
| @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) { | |||||
| // c端用户应该只能看到自己的订单 | |||||
| if (order == null){ | |||||
| order = new TtOrder(); | |||||
| } | |||||
| Long memberId; | |||||
| try { | |||||
| memberId = getMemberId(); | |||||
| } catch (MallinkException e) { | |||||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||||
| } | |||||
| order.setCUserId(memberId); | |||||
| return new ResultData(ttOrderService.listAsPage(order, pageNum, pageSize)); | |||||
| } | |||||
| @ApiOperation(value = "下订单", notes = "{\"couponChannelId\":\"String\",\"couponId\":\"String\",\"press\":\"String\",\"orderGroupId\":\"String\",\"formId\":\"String\"}") | |||||
| @PostMapping("save") | |||||
| public ResultData saveOrder(@RequestBody Map<String, String> paramMap) { | |||||
| String couponIdStr = paramMap.get("couponId"); | |||||
| if (StringUtils.isBlank(couponIdStr) || couponIdStr.equalsIgnoreCase(Constant.UNDEFINED)) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponId不能为空"); | |||||
| } | |||||
| Long couponId; | |||||
| try { | |||||
| couponId = Long.valueOf(couponIdStr); | |||||
| } catch (NumberFormatException e) { | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "couponId: " + couponIdStr + ", e: " + e.getMessage()); | |||||
| } | |||||
| Long memberId; | |||||
| try { | |||||
| memberId = getMemberId(); | |||||
| } catch (MallinkException e) { | |||||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||||
| } | |||||
| return ttOrderService.saveOrder(couponId,memberId,EnumPayWay.PAY_WAY_TT,getTenantInfo()); | |||||
| } | |||||
| @ApiOperation(value = "取消订单", notes = "{\"orderId\":\"string\"}") | |||||
| @PostMapping("cancel") | |||||
| public ResultData cancelOrder(@RequestBody Map<String, String> paramMap) { | |||||
| String orderIdStr = paramMap.get("orderId"); | |||||
| if (StringUtils.isBlank(orderIdStr) || orderIdStr.equalsIgnoreCase(Constant.UNDEFINED)) { | |||||
| 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()); | |||||
| } | |||||
| try { | |||||
| return ttOrderService.cancelOrder(orderId,memberId); | |||||
| } catch (Exception e) { | |||||
| logger.error("取消订单失败: " + e.getMessage()); | |||||
| return new ResultData(ErrorCode.ORDER_IS_FAIL.getCode(), "取消订单失败: " + e.getMessage()); | |||||
| } | |||||
| } | |||||
| @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()); | |||||
| } | |||||
| Long memberId; | |||||
| try { | |||||
| memberId = getMemberId(); | |||||
| } catch (MallinkException e) { | |||||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||||
| } | |||||
| TtOrder order = ttOrderService.detail(id,memberId); | |||||
| return new ResultData(order); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,223 @@ | |||||
| 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()); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -38,7 +38,7 @@ import java.util.Map; | |||||
| @RestController | @RestController | ||||
| @RequestMapping("/api/user") | @RequestMapping("/api/user") | ||||
| @Api(description = "用户登陆授权相关接口") | @Api(description = "用户登陆授权相关接口") | ||||
| public class WxUserGrantController extends BaseController { | |||||
| public class TtUserGrantController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||||