| | |
| | | package cc.mrbird.febs; |
| | | |
| | | import cc.mrbird.febs.mall.entity.MallOrderItem; |
| | | import cc.mrbird.febs.mall.mapper.MallOrderInfoMapper; |
| | | import cc.mrbird.febs.mall.mapper.MallOrderItemMapper; |
| | | import cc.mrbird.febs.mall.service.IAgentService; |
| | | import cc.mrbird.febs.mall.service.IMallAchieveService; |
| | | import cc.mrbird.febs.mall.service.IMemberProfitService; |
| | | import cc.mrbird.febs.common.entity.FebsResponse; |
| | | import cc.mrbird.febs.common.enumerates.DataDictionaryEnum; |
| | | import cc.mrbird.febs.common.enumerates.FlowTypeEnum; |
| | | import cc.mrbird.febs.common.enumerates.MoneyFlowTypeEnum; |
| | | import cc.mrbird.febs.common.utils.MallUtils; |
| | | import cc.mrbird.febs.mall.dto.ApiLeaderOrderConfirmDto; |
| | | import cc.mrbird.febs.mall.entity.*; |
| | | import cc.mrbird.febs.mall.mapper.*; |
| | | import cc.mrbird.febs.mall.service.*; |
| | | import cc.mrbird.febs.pay.model.WxGenerateQrCodeDto; |
| | | import cc.mrbird.febs.pay.service.IXcxPayService; |
| | | import cc.mrbird.febs.rabbit.consumer.AgentConsumer; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.date.DateTime; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import org.apache.commons.collections.CollectionUtils; |
| | | import org.junit.jupiter.api.Test; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.test.context.SpringBootTest; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author wzy |
| | |
| | | |
| | | @Test |
| | | public void dynamicProfit() { |
| | | memberProfitService.dynamicProfit(16L); |
| | | memberProfitService.dynamicProfit(21L); |
| | | } |
| | | @Test |
| | | public void agentProfit() { |
| | |
| | | |
| | | @Test |
| | | public void staticProfit() { |
| | | memberProfitService.staticProfit(); |
| | | memberProfitService.staticProfit(new Date()); |
| | | } |
| | | |
| | | @Test |
| | | public void thankfulProfit() { |
| | | memberProfitService.thankfulProfit(); |
| | | memberProfitService.thankfulProfit(new Date()); |
| | | } |
| | | |
| | | @Test |
| | |
| | | |
| | | @Test |
| | | public void directorProfitTest() { |
| | | memberProfitService.storeAndDirectorProfit(null); |
| | | memberProfitService.storeAndDirectorProfit(new Date()); |
| | | } |
| | | |
| | | @Autowired |
| | |
| | | mallAchieveService.add(item.getId()); |
| | | } |
| | | } |
| | | |
| | | @Test |
| | | public void paramTest() { |
| | | Map<String, Integer> map = new HashMap<>(); |
| | | BigDecimal amount = new BigDecimal("100"); |
| | | map.put("amount", 1); |
| | | changeAmount(map); |
| | | System.out.println(map.get("amount")); |
| | | } |
| | | |
| | | public void changeAmount(Map<String, Integer> amount) { |
| | | amount.put("amount", 2); |
| | | } |
| | | |
| | | @Resource |
| | | RestTemplate restTemplate; |
| | | |
| | | @Test |
| | | public void getWeChatAccessToken() { |
| | | |
| | | String appId = "wx5cc58f796224af61"; |
| | | String appSecret = "71403646f666f9b9dca308d4f357765c"; |
| | | String url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + appId + "&secret=" + appSecret; |
| | | String jsonStr = restTemplate.getForObject(url, String.class); |
| | | |
| | | /** |
| | | * 返回结果 |
| | | * {"access_token":"ACCESS_TOKEN","expires_in":7200} |
| | | */ |
| | | if (!jsonStr.contains("access_token")) { |
| | | System.out.println("获取微信access_token失败"); |
| | | } |
| | | |
| | | JSONObject jsonObject = JSON.parseObject(jsonStr); |
| | | System.out.println(jsonObject.get("access_token").toString()); |
| | | } |
| | | @Resource |
| | | IApiMallTeamLeaderService iApiMallTeamLeaderService; |
| | | |
| | | @Test |
| | | public void confirm(){ |
| | | // ApiLeaderOrderConfirmDto apiLeaderOrderConfirmDto = new ApiLeaderOrderConfirmDto(); |
| | | // apiLeaderOrderConfirmDto.setIds("90"); |
| | | // iApiMallTeamLeaderService.leaderOrderConfirm(apiLeaderOrderConfirmDto); |
| | | String productNames = getProductNames(35L, 106L); |
| | | System.out.println(productNames); |
| | | } |
| | | |
| | | /** |
| | | * 根据用户ID和订单ID获取所购买商品名称 |
| | | * @return 所含商品名称(多个以","隔开) |
| | | */ |
| | | public String getProductNames(Long memberId, Long orderId) { |
| | | MallOrderInfo mallOrderInfo = mallOrderInfoMapper.selectOrderByMemberIdAndId(memberId, orderId); |
| | | List<MallOrderItem> details = mallOrderInfo.getItems(); |
| | | if (CollectionUtils.isEmpty(details)) { |
| | | return ""; |
| | | } |
| | | StringBuffer productNameBuffer = new StringBuffer(); |
| | | Integer maxLength = 30; |
| | | for (int i = 0; i< details.size(); i++) { |
| | | MallOrderItem mallOrderItem = details.get(i); |
| | | String goodsName = mallOrderItem.getGoodsName(); |
| | | if (goodsName == null) { |
| | | continue; |
| | | } |
| | | if (i == 0 && goodsName.length() > maxLength) { |
| | | productNameBuffer.append(goodsName.substring(0, maxLength) + "..."); |
| | | break; |
| | | } |
| | | if ((productNameBuffer.length() + goodsName.length()) > maxLength) { |
| | | productNameBuffer.append("等"); |
| | | break; |
| | | } |
| | | productNameBuffer.append(goodsName + ","); |
| | | } |
| | | String productNames = productNameBuffer.toString(); |
| | | if (productNames.endsWith(",")) { |
| | | productNames = productNames.substring(0, productNames.length() - 1); |
| | | } |
| | | if (productNames.endsWith(",等")) { |
| | | productNames = productNames.substring(0, productNames.length() - 2) + "等"; |
| | | } |
| | | return productNames; |
| | | } |
| | | @Autowired |
| | | private IXcxPayService iXcxPayService; |
| | | |
| | | @Test |
| | | public void qrcode(){ |
| | | WxGenerateQrCodeDto wxGenerateQrCodeDto = new WxGenerateQrCodeDto(); |
| | | wxGenerateQrCodeDto.setPage("wxGenerateQrCodeDto"); |
| | | wxGenerateQrCodeDto.setScene("15"); |
| | | FebsResponse febsResponse = iXcxPayService.generateQrCode(wxGenerateQrCodeDto); |
| | | String data = febsResponse.get("data").toString(); |
| | | System.out.println(data); |
| | | } |
| | | |
| | | |
| | | // |
| | | // @Autowired |
| | | // private MallOrderInfoMapper mallOrderInfoMapper; |
| | | // |
| | | // @Autowired |
| | | // private MallGoodsSkuMapper mallGoodsSkuMapper; |
| | | |
| | | @Autowired |
| | | private MallLeaderAchieveMapper mallLeaderAchieveMapper; |
| | | // |
| | | // @Autowired |
| | | // private MallTeamLeaderMapper mallTeamLeaderMapper; |
| | | // |
| | | // @Autowired |
| | | // private IMemberProfitService memberProfitService; |
| | | |
| | | // @Autowired |
| | | // private IMallAchieveService mallAchieveService; |
| | | |
| | | @Autowired |
| | | private DataDictionaryCustomMapper dataDictionaryCustomMapper; |
| | | |
| | | @Autowired |
| | | private MallMemberMapper mallMemberMapper; |
| | | |
| | | @Autowired |
| | | private IMallMoneyFlowService mallMoneyFlowService; |
| | | |
| | | @Autowired |
| | | private IApiMallMemberWalletService memberWalletService; |
| | | |
| | | @Test |
| | | public void achieve(){ |
| | | DataDictionaryCustom dicBonusSwitch = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.BONUS_SWITCH.getType(), DataDictionaryEnum.BONUS_SWITCH.getCode()); |
| | | String bonusSwitch = dicBonusSwitch.getValue(); |
| | | if("1".equals(bonusSwitch)){ |
| | | DataDictionaryCustom dicBonusPercent = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.BONUS_PERCENT.getType(), DataDictionaryEnum.BONUS_PERCENT.getCode()); |
| | | BigDecimal bonusPercent = new BigDecimal(dicBonusPercent.getValue()).setScale(2,BigDecimal.ROUND_DOWN);; |
| | | //获取每日提成总数 |
| | | /** |
| | | * a.unique_code uniqueCode 团长特征码 |
| | | * , IFNULL(sum(a.amount),0) amount 每日提成总金额 |
| | | */ |
| | | // DateTime dateTime = DateUtil.offsetDay(new Date(), -1); |
| | | DateTime dateTime = DateUtil.offsetDay(new Date(), 0); |
| | | List<Map<String, String>> allLeaderAchieve = mallLeaderAchieveMapper.selectListByStateAndCreateTimeAndUniqueCode(MallLeaderAchieve.STATE_ONE,dateTime); |
| | | if (CollUtil.isNotEmpty(allLeaderAchieve)) { |
| | | for (Map<String, String> map : allLeaderAchieve) { |
| | | String uniqueCode = map.get("uniqueCode"); |
| | | Object amountOrder = map.get("amount"); |
| | | //直接舍弃小数点的第三位 |
| | | BigDecimal amount = new BigDecimal(String.valueOf(amountOrder)).setScale(2,BigDecimal.ROUND_DOWN); |
| | | BigDecimal achieveMoney = amount.multiply(bonusPercent).setScale(2,BigDecimal.ROUND_DOWN); |
| | | MallMember mallMember = mallMemberMapper.selectInfoByInviteId(uniqueCode); |
| | | memberWalletService.addBalance(achieveMoney,mallMember.getId()); |
| | | String achieveNo = "TC."+ MallUtils.getOrderNum(); |
| | | mallMoneyFlowService.addMoneyFlow( |
| | | mallMember.getId(), |
| | | achieveMoney, |
| | | MoneyFlowTypeEnum.LEADERACHIEVE.getValue(), |
| | | achieveNo, |
| | | FlowTypeEnum.BALANCE.getValue()); |
| | | |
| | | |
| | | //更新到已提成状态 |
| | | mallLeaderAchieveMapper.updateByUniqueCodeStateAndTime(DateUtil.date(),uniqueCode,MallLeaderAchieve.STATE_ONE,dateTime); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | @Test |
| | | public void testAddress(){ |
| | | MallOrderInfo orderInfo = mallOrderInfoMapper.selectOrderDetailsById(266L); |
| | | System.out.println(orderInfo.getLeaderLatitude()); |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | BigDecimal amount = new BigDecimal("0.15").setScale(2,BigDecimal.ROUND_DOWN); |
| | | System.out.println(amount); |
| | | } |
| | | } |