|
|
@@ -1,23 +1,26 @@
|
|
|
package com.izouma.awesomeadmin.service.impl;
|
|
|
|
|
|
-import java.util.*;
|
|
|
-
|
|
|
+import com.izouma.awesomeadmin.constant.AppConstant;
|
|
|
+import com.izouma.awesomeadmin.dao.MemberCoinMapper;
|
|
|
+import com.izouma.awesomeadmin.dao.PayCodeOrderMapper;
|
|
|
import com.izouma.awesomeadmin.dao.PayCodeStockMapper;
|
|
|
import com.izouma.awesomeadmin.dao.ProductInfoMapper;
|
|
|
+import com.izouma.awesomeadmin.dto.Page;
|
|
|
import com.izouma.awesomeadmin.dto.Result;
|
|
|
-import com.izouma.awesomeadmin.model.MemberTicket;
|
|
|
-import com.izouma.awesomeadmin.model.PayCodeStock;
|
|
|
-import com.izouma.awesomeadmin.model.ProductInfo;
|
|
|
+import com.izouma.awesomeadmin.model.*;
|
|
|
+import com.izouma.awesomeadmin.service.ChannelInfoService;
|
|
|
import com.izouma.awesomeadmin.service.MemberTicketService;
|
|
|
+import com.izouma.awesomeadmin.service.PayCodeOrderService;
|
|
|
+import com.izouma.awesomeadmin.service.UserInfoService;
|
|
|
import com.izouma.awesomeadmin.util.MbappUtil;
|
|
|
import org.apache.log4j.Logger;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-import com.izouma.awesomeadmin.constant.AppConstant;
|
|
|
-import com.izouma.awesomeadmin.dto.Page;
|
|
|
-import com.izouma.awesomeadmin.model.PayCodeOrder;
|
|
|
-import com.izouma.awesomeadmin.service.PayCodeOrderService;
|
|
|
-import com.izouma.awesomeadmin.dao.PayCodeOrderMapper;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* service接口实现类
|
|
|
@@ -40,6 +43,15 @@ public class PayCodeOrderServiceImpl implements PayCodeOrderService {
|
|
|
@Autowired
|
|
|
private MemberTicketService memberTicketService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private UserInfoService userInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ChannelInfoService channelInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MemberCoinMapper memberCoinMapper;
|
|
|
+
|
|
|
/*generatedStart*/
|
|
|
|
|
|
@Override
|
|
|
@@ -223,6 +235,56 @@ public class PayCodeOrderServiceImpl implements PayCodeOrderService {
|
|
|
|
|
|
payCodeOrderMapper.updateByPrimaryKeySelective(record);
|
|
|
|
|
|
+ /**
|
|
|
+ * 二级分润 开始
|
|
|
+ */
|
|
|
+ try {
|
|
|
+ int userId = Integer.valueOf(payCodeOrder.getUserId());
|
|
|
+ UserInfo userInfo = userInfoService.getUserInfoById(userId + "");
|
|
|
+ ChannelInfo channelInfo = channelInfoService.getChannelInfoById(userInfo.getChannel() + "");
|
|
|
+ if (channelInfo != null) {
|
|
|
+ int ratio = channelInfo.getRatio();
|
|
|
+ double money = payCodeOrder.getMoney().doubleValue() * ratio / 100.0;
|
|
|
+ int ratio2 = channelInfo.getRatio2();
|
|
|
+ double money2 = payCodeOrder.getMoney().doubleValue() * ratio2 / 100.0;
|
|
|
+
|
|
|
+ Integer recommenderId = userInfo.getRecommender();
|
|
|
+
|
|
|
+ if (recommenderId != null) {
|
|
|
+
|
|
|
+ UserInfo recommender = userInfoService.getUserInfoById(recommenderId + "");
|
|
|
+ if (recommender != null) {
|
|
|
+
|
|
|
+ fenrun(money, recommender);
|
|
|
+ Integer recommenderId2 = recommender.getRecommender();
|
|
|
+
|
|
|
+
|
|
|
+ if (recommenderId2 != null) {
|
|
|
+
|
|
|
+ UserInfo recommender2 = userInfoService.getUserInfoById(recommenderId2 + "");
|
|
|
+ if (recommender2 != null) {
|
|
|
+
|
|
|
+ fenrun(money2, recommender2);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error("渠道分成异常", e);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 二级分润 结束
|
|
|
+ */
|
|
|
+
|
|
|
return new Result(true, "付款成功");
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
@@ -231,6 +293,34 @@ public class PayCodeOrderServiceImpl implements PayCodeOrderService {
|
|
|
return new Result(false, "付款失败");
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 分润
|
|
|
+ *
|
|
|
+ * @param money
|
|
|
+ * @param recommender
|
|
|
+ */
|
|
|
+ private void fenrun(double money, UserInfo recommender) {
|
|
|
+ UserInfo updateUser = new UserInfo();
|
|
|
+ updateUser.setId(recommender.getId());
|
|
|
+
|
|
|
+
|
|
|
+ double balance = recommender.getMoneyCoin();
|
|
|
+ double moneyCoin = balance + money;
|
|
|
+
|
|
|
+ MemberCoin memberCoin = new MemberCoin();
|
|
|
+
|
|
|
+ memberCoin.setUserId(recommender.getId());
|
|
|
+ memberCoin.setCreateUser("管理员");
|
|
|
+ memberCoin.setMoney(BigDecimal.valueOf(money));
|
|
|
+ memberCoin.setBalance(BigDecimal.valueOf(moneyCoin));
|
|
|
+ memberCoin.setTypeFlag(AppConstant.CoinType.SONG);
|
|
|
+ memberCoin.setRemark("下级购买参赛券赠送:" + money + "余额");
|
|
|
+ memberCoinMapper.insertSelective(memberCoin);
|
|
|
+
|
|
|
+ updateUser.setMoneyCoin(moneyCoin);
|
|
|
+ userInfoService.updateUserInfo(updateUser);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public Result cancel(PayCodeOrder record) {
|
|
|
logger.info("cancel 付款码取消");
|