| @@ -5,7 +5,7 @@ import com.alibaba.fastjson.JSONObject; | |||
| import com.baomidou.mybatisplus.annotation.TableField; | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| import com.fasterxml.jackson.annotation.JsonIgnore; | |||
| import com.iformall.domain.po.base.BaseTenantEntity; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import lombok.Data; | |||
| @@ -22,13 +22,14 @@ import java.util.Objects; | |||
| @Data | |||
| @ToString(callSuper = true) | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class WxCUserBasicInfo extends TenantEntity { | |||
| public class WxCUserBasicInfo extends BaseEntity { | |||
| protected Long id; | |||
| @JsonIgnore | |||
| protected Date scoreDate; | |||
| @io.swagger.annotations.ApiModelProperty(value="如果是集团版的,存集团版的tenantId,如果是商场,则存商场",name="sex") | |||
| private String finalTenantId; | |||
| @Excel(name="姓名",width = 20,orderNum = "1") | |||
| @@ -169,18 +170,11 @@ public class WxCUserBasicInfo extends TenantEntity { | |||
| return Objects.hash(this.phone); | |||
| } | |||
| public void undateFinalTenantId(){ | |||
| setFinalTenantId(getTenantId()); | |||
| if(StringUtils.isNotBlank(getParentTenantId())){ | |||
| setFinalTenantId(getParentTenantId()); | |||
| } | |||
| } | |||
| public void undateFinalTenantId(TenantEntity tenantEntity){ | |||
| setFinalTenantId(tenantEntity.getTenantId()); | |||
| if(StringUtils.isNotBlank(tenantEntity.getParentTenantId())){ | |||
| setFinalTenantId(tenantEntity.getParentTenantId()); | |||
| } | |||
| } | |||
| // public void undateFinalTenantId(TenantEntity tenantEntity){ | |||
| // setFinalTenantId(tenantEntity.getTenantId()); | |||
| // if(StringUtils.isNotBlank(tenantEntity.getParentTenantId())){ | |||
| // setFinalTenantId(tenantEntity.getParentTenantId()); | |||
| // } | |||
| // } | |||
| } | |||
| @@ -34,6 +34,14 @@ public class BaseTenantEntity extends BaseEntity { | |||
| setParentTenantId(info.getParentTenantId()); | |||
| } | |||
| } | |||
| public void updateTenantInfoByUserInfo(WxCUserBasicInfo userBase) { | |||
| log.info("info.tenantId:"+info.getTenantId()+". info.parentTenantId:"+info.getParentTenantId()+"."); | |||
| setTenantId(info.getTenantId()); | |||
| if (StringUtils.isNotBlank(info.getParentTenantId())) { | |||
| setParentTenantId(info.getParentTenantId()); | |||
| } | |||
| } | |||
| public void updateTenantInfo(BaseTenantEntity info) { | |||
| setTenantId(info.getTenantId()); | |||
| @@ -542,13 +542,13 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { | |||
| @Override | |||
| public List<WxCUserBasicInfo> findByPhone(TenantEntity tenantEntity, String phone) { | |||
| WxCUserBasicInfo basicQ = new WxCUserBasicInfo(); | |||
| basicQ.updateTenantInfo(tenantEntity); | |||
| basicQ.undateFinalTenantId(tenantEntity); | |||
| basicQ.setPhone(phone); | |||
| List<WxCUserBasicInfo> basicInfos = wxCUserBasicInfoMapper.selectList(new QueryWrapper(basicQ)); | |||
| if (basicInfos != null && basicInfos.size() > 0) { | |||
| WxCUserBasicInfo wxCUserBasicInfo = basicInfos.get(0); | |||
| if (wxCUserBasicInfo.getPoins() != null) { | |||
| List<WxLevelConfig> levelList = wxLevelConfigService.getByTenantId(wxCUserBasicInfo.getTenantId()); | |||
| List<WxLevelConfig> levelList = wxLevelConfigService.getByTenantId(wxCUserBasicInfo.getFinalTenantId()); | |||
| String level = WxLevelConfigService.DEFAULT_LEVEL; | |||
| for(WxLevelConfig levelConfig: levelList) { | |||
| if (wxCUserBasicInfo.getPoins() >= levelConfig.getPoints()) { | |||
| @@ -749,7 +749,7 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { | |||
| WxCUserBasicInfo userBase = new WxCUserBasicInfo(); | |||
| userBase.updateTenantInfo(tenantEntity); | |||
| userBase.undateFinalTenantId(tenantEntity); | |||
| userBase.setName(uBase.getName()); | |||
| if (uBase.getSex() == null) { | |||
| userBase.setSex(0); | |||
| @@ -23,7 +23,7 @@ import com.iformall.service.pay.entity.PayExtraParam; | |||
| import com.iformall.service.pay.service.pay.CDrivingPayService; | |||
| import com.iformall.service.pay.service.pay.CPassivePayService; | |||
| import com.iformall.service.pay.service.pay.PayAdapterService; | |||
| import com.iformall.service.pay.service.pay.entity.CreateCUser; | |||
| import com.iformall.service.pay.service.pay.entity.GetUser; | |||
| import com.iformall.service.pay.service.pay.entity.PayAdapterResult; | |||
| import com.iformall.service.pay.service.pay.entity.PayQueryAdapterResult; | |||
| import com.iformall.service.pay.service.share.entity.ShareNotifyAdapterResult; | |||
| @@ -480,10 +480,23 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| //支付失败,更新record,支付成功,则调用 | |||
| if (payResult.isSuccess()) { | |||
| handleMicroOrderPaySuccess(payResult.getData(), payResult.getTransactionId(),payWay,record,user, appInfo, params); | |||
| try { | |||
| handleMicroOrderPaySuccess(payResult.getData(), payResult.getTransactionId(),payWay,record,user, appInfo, params); | |||
| }catch(Exception e) { | |||
| logger.error("do handleMicroOrderPaySuccess() error.",e); | |||
| try { | |||
| record.setFailReason("do handleMicroOrderPaySuccess() error."+e.getMessage()); | |||
| wxPayOrderMapper.updateById(record); | |||
| } catch (Exception ex) { | |||
| logger.error("pay order update error: " + ex.getMessage()); | |||
| throw new MallinkException(ErrorCode.DB_FAIL); | |||
| } | |||
| throw new MallinkException(ErrorCode.DB_FAIL); | |||
| } | |||
| return new ResultData(Result.SUCCESS, "创建支付订单成功", payResult.getData()); | |||
| }else { | |||
| try { | |||
| record.setFailReason(payResult.getMsg()); | |||
| wxPayOrderMapper.updateById(record); | |||
| } catch (Exception e) { | |||
| logger.error("pay order update error: " + record.toString()); | |||
| @@ -769,7 +782,12 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| logger.error("pay success handle, order " + record.getOrderId() + " not found , payOrderid : " + record.getPayOrderNo()); | |||
| throw new MallinkException(ErrorCode.ORDER_IS_NOT_FIND); | |||
| } | |||
| if (null != cUserId) { | |||
| WxOrder __order = new WxOrder(); | |||
| __order.setId(order.getId()); | |||
| __order.setCUserId(cUserId); | |||
| wxOrderMapper.updateById(__order); | |||
| } | |||
| // 修改支付订单状态 | |||
| WxPayOrder updateOrder = new WxPayOrder(); | |||
| @@ -843,8 +861,9 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||
| public void handleMicroOrderPaySuccess(Object result,String transcationId,EnumPayWay payWay, WxPayOrder record ,WxMerchantBUser user,WxAppinfo appInfo,PayExtraParam params) { | |||
| //B端操作,需要生成cUser | |||
| CreateCUser cUser = null; | |||
| GetUser cUser = null; | |||
| try { | |||
| 11111111111111111 | |||
| cUser = payServiceFactory.getCPassivePayService(payWay.getCode()).createCUserAfterPay(result, appInfo); | |||
| } catch (Exception e1) { | |||
| logger.error("创建C端用户失败: " ,e1); | |||
| @@ -8,7 +8,7 @@ import com.iformall.domain.po.WxPayAccount; | |||
| import com.iformall.domain.po.WxPayOrder; | |||
| import com.iformall.enums.EnumPayShare; | |||
| import com.iformall.service.pay.entity.PayExtraParam; | |||
| import com.iformall.service.pay.service.pay.entity.CreateCUser; | |||
| import com.iformall.service.pay.service.pay.entity.CreateUser; | |||
| import com.iformall.service.pay.service.pay.entity.PayAdapterResult; | |||
| /** | |||
| @@ -18,7 +18,7 @@ import com.iformall.service.pay.service.pay.entity.PayAdapterResult; | |||
| public interface CPassivePayService extends PayAdapterService{ | |||
| /** | |||
| * 支付成功之后生成用户 | |||
| * 支付成功之后查询会员 | |||
| * @param result 支付API或者查询API 接口返回的对象 | |||
| * @param payAccount | |||
| * @param order | |||
| @@ -29,6 +29,6 @@ public interface CPassivePayService extends PayAdapterService{ | |||
| * @param params | |||
| * @throws Exception | |||
| */ | |||
| public CreateCUser createCUserAfterPay(Object result,WxAppinfo appInfo) throws Exception; | |||
| public CreateUser createCUserAfterPay(Object result,WxAppinfo appInfo) throws Exception; | |||
| } | |||
| @@ -9,7 +9,7 @@ import lombok.Data; | |||
| @Data | |||
| @AllArgsConstructor | |||
| public class CreateCUser implements Serializable{ | |||
| public class CreateUser implements Serializable{ | |||
| private static final long serialVersionUID = 877618734961866171L; | |||
| @@ -8,8 +8,10 @@ import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.IdWorker; | |||
| import com.iformall.domain.po.WxAppinfo; | |||
| import com.iformall.domain.po.WxCUser; | |||
| import com.iformall.domain.po.WxCUserBasicInfo; | |||
| import com.iformall.domain.po.WxOrder; | |||
| import com.iformall.domain.po.WxPayAccount; | |||
| import com.iformall.domain.po.WxPayOrder; | |||
| @@ -17,6 +19,7 @@ import com.iformall.enums.EnumPayMode; | |||
| import com.iformall.enums.EnumPayShare; | |||
| import com.iformall.enums.EnumUserIsSubscribe; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.mapper.WxCUserBasicInfoMapper; | |||
| import com.iformall.mapper.WxCUserMapper; | |||
| import com.iformall.pay.WxMicroPayOrderP; | |||
| import com.iformall.pay.WxMicroPayOrderSP; | |||
| @@ -25,7 +28,7 @@ import com.iformall.pay.WxPayment; | |||
| import com.iformall.service.WxCUserService; | |||
| import com.iformall.service.pay.entity.PayExtraParam; | |||
| import com.iformall.service.pay.service.pay.CPassivePayService; | |||
| import com.iformall.service.pay.service.pay.entity.CreateCUser; | |||
| import com.iformall.service.pay.service.pay.entity.CreateUser; | |||
| import com.iformall.service.pay.service.pay.entity.PayAdapterResult; | |||
| import com.iformall.service.pay.service.pay.entity.PayQueryAdapterResult; | |||
| import com.iformall.service.pay.service.pay.wx.BaseWxPayAdapterService; | |||
| @@ -196,9 +199,11 @@ public class WxMiniMaPayAdapterService extends BaseWxPayAdapterService implement | |||
| WxCUserMapper wxCUserMapper; | |||
| @Autowired | |||
| WxCUserService wxCUserService; | |||
| @Autowired | |||
| WxCUserBasicInfoMapper wxCUserBasicInfoMapper; | |||
| @Override | |||
| public CreateCUser createCUserAfterPay(Object result,WxAppinfo appInfo) throws Exception { | |||
| public CreateUser createCUserAfterPay(Object result,WxAppinfo appInfo) throws Exception { | |||
| // add c_user, 收银台支付和券支付可能不是同一个人 | |||
| Date curDate = new Date(); | |||
| WxCUser userQ = new WxCUser(); | |||
| @@ -207,28 +212,19 @@ public class WxMiniMaPayAdapterService extends BaseWxPayAdapterService implement | |||
| String isSubscribe = returnMap.get("sub_is_subscribe"); | |||
| userQ.setOpenId(openId); | |||
| userQ.setAppId(appInfo.getAppId()); | |||
| WxCUser user1 = wxCUserMapper.findByOpenId(userQ); | |||
| if (user1 == null) { | |||
| userQ.setCreateDate(curDate); | |||
| userQ.setUpdateDate(curDate); | |||
| if ("N".equalsIgnoreCase(isSubscribe)) { | |||
| userQ.setIsSubscribe(EnumUserIsSubscribe.NO.getCode()); | |||
| } else { | |||
| userQ.setIsSubscribe(EnumUserIsSubscribe.YES.getCode()); | |||
| } | |||
| wxCUserService.saveOrUpdate(userQ); | |||
| } else { | |||
| userQ.setId(user1.getId()); | |||
| userQ.setUpdateDate(curDate); | |||
| userQ.setLoginCount(user1.getLoginCount()); | |||
| if ("N".equalsIgnoreCase(isSubscribe)) { | |||
| userQ.setIsSubscribe(EnumUserIsSubscribe.NO.getCode()); | |||
| } else { | |||
| userQ.setIsSubscribe(EnumUserIsSubscribe.YES.getCode()); | |||
| } | |||
| wxCUserService.saveOrUpdate(userQ); | |||
| user1 = new WxCUser(); | |||
| user1.setAppId(appInfo.getAppId()); | |||
| user1.setOpenId(openId); | |||
| 1111111111111111 | |||
| user1.updateTenantInfo(appInfo); | |||
| wxCUserService.saveOrUpdate(user1); | |||
| }else { | |||
| } | |||
| return new CreateCUser(userQ.getId(),userQ.getUserId()); | |||
| return null; | |||
| } | |||
| @Override | |||