zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/weixinUtil/WeixinServiceUtil.java
@@ -144,7 +144,6 @@ */ public JsApiPayComResData comPay(String desc, String outTradeNo,int totalFee, String openid,Long companyId){ JsApiPayComResData result=null; //boolean flag=false; try { JsApiPayBusiness jsApiPayBusiness = new JsApiPayBusiness(); // TODO 企业付款 zq-erp/src/main/java/com/matrix/core/tools/StringUtils.java
@@ -1,15 +1,5 @@ package com.matrix.core.tools; import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.List; import java.util.Random; import java.util.UUID; import java.util.regex.Matcher; import java.util.regex.Pattern; import com.matrix.core.exception.GlobleException; import net.sourceforge.pinyin4j.PinyinHelper; import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType; @@ -18,6 +8,11 @@ import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType; import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination; import org.apache.commons.collections.CollectionUtils; import java.io.UnsupportedEncodingException; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * 字符串操作类,转换数据类型,切割字符串,对象比较等操作 @@ -404,6 +399,8 @@ return sb.toString(); } /** * 用逗号分开的存的id是否包含对应的id 如比较 123,123,124 中是否包含12这个主键 比对的方法是 字符串中是否包含"^12$" * "^12,.*" 或者 ".+,12$" 或者 ".+,12,$" 或者 ".+,12,.+" 字符串 zq-erp/src/main/java/com/matrix/system/fenxiao/dao/ShopRevenueFlowDao.java
@@ -1,7 +1,12 @@ package com.matrix.system.fenxiao.dao; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.matrix.system.fenxiao.entity.ShopRevenueFlow; import com.matrix.system.shopXcx.api.dto.RevenueFlowDto; import com.matrix.system.shopXcx.vo.SalesOrderVo; import org.apache.ibatis.annotations.Param; /** * @description 收益流水 @@ -10,4 +15,5 @@ */ public interface ShopRevenueFlowDao extends BaseMapper<ShopRevenueFlow> { IPage<SalesOrderVo> selectRevenuFlowList(Page<SalesOrderVo> page, @Param("record") RevenueFlowDto revenueFlowDto); } zq-erp/src/main/java/com/matrix/system/fenxiao/entity/ShopRevenueFlow.java
@@ -3,6 +3,7 @@ import com.baomidou.mybatisplus.annotation.TableName; import com.matrix.core.anotations.Extend; import com.matrix.system.score.entity.BaseEntity; import io.swagger.annotations.ApiModelProperty; import lombok.Data; /** @@ -23,36 +24,35 @@ /** * 用户id */ @ApiModelProperty(hidden = true) private String userId; /** * 收益说明 */ @ApiModelProperty(value = "收益说明") private String revenueContent; /** * 收益金额 */ @ApiModelProperty(value = "收益金额") private Double amount; /** * 原始订单ID */ @ApiModelProperty(value = "原始订单ID") private Long businessId; /** * 公司ID */ @ApiModelProperty(hidden = true) private Long companyId; zq-erp/src/main/java/com/matrix/system/hive/service/CodeService.java
@@ -25,6 +25,8 @@ */ public String getOrderCode(); String get32LenNumberCode(); public String getFlowCode(); /** zq-erp/src/main/java/com/matrix/system/hive/service/imp/CodeServiceImpl.java
@@ -9,9 +9,9 @@ import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Random; /** * * @@ -96,6 +96,23 @@ } @Override public String get32LenNumberCode(){ DateFormat fmt = new SimpleDateFormat("yyyyMMddHHmmss"); Date date=new Date(); String str = "0123456789"; Random random = new Random(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < 18; i++) { int number = random.nextInt(str.length()); sb.append(str.charAt(number)); } return fmt.format(date)+sb.toString(); } @Override public String getFlowCode() { return "F" + getNowTimeString(); } zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxSalesWithdrawalAction.java
New file @@ -0,0 +1,127 @@ package com.matrix.system.shopXcx.api.action; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.matrix.biz.bean.BizUser; import com.matrix.biz.dao.BizUserDao; import com.matrix.component.redis.RedisUserLoginUtils; import com.matrix.component.wechat.externalInterface.weixinUtil.WeixinServiceUtil; import com.matrix.core.constance.MatrixConstance; import com.matrix.core.pojo.AjaxResult; import com.matrix.core.pojo.BasePageQueryDto; import com.matrix.system.fenxiao.dao.ShopRevenueFlowDao; import com.matrix.system.fenxiao.entity.ShopRevenueFlow; import com.matrix.system.hive.service.CodeService; import com.matrix.system.shopXcx.api.dto.RevenueFlowDto; import com.matrix.system.shopXcx.api.dto.WithdrawalCashDto; import com.matrix.system.shopXcx.vo.SalesOrderVo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.Date; /** * @author jyy * @date 2021-03-10 **/ @Api(tags = "提现接口类") @RestController @RequestMapping(value = "/wxapi/salesWithdrawal") public class WxSalesWithdrawalAction { @Autowired private RedisUserLoginUtils redisUserLoginUtils; @Autowired private BizUserDao bizUserDao; @Autowired private ShopRevenueFlowDao revenueFlowDao; @Autowired private ShopRevenueFlowDao shopRevenueFlowDao; @Autowired WeixinServiceUtil weixinServiceUtil; @Autowired CodeService codeService; @ApiOperation(value = "获取收支明细", notes = "") @PostMapping(value = "/getInvitationuserList") @ApiResponses({ @ApiResponse(code = 200, message = "ok", response = ShopRevenueFlow.class) }) AjaxResult getInvitationuserList(@RequestBody @Validated RevenueFlowDto revenueFlowDto) { BizUser loginUser = redisUserLoginUtils.getLoginUser(BizUser.class); Page<SalesOrderVo> page=new Page<>(revenueFlowDto.getPageNum(),revenueFlowDto.getPageSize()); revenueFlowDto.setUserId(loginUser.getOpenId()); IPage<SalesOrderVo> shopSalesmanApplyIPage = revenueFlowDao.selectRevenuFlowList(page, revenueFlowDto); AjaxResult result=AjaxResult.buildSuccessInstance(shopSalesmanApplyIPage.getRecords()); return result; } @ApiOperation(value = "提现", notes = "") @PostMapping(value = "/withdrawalCash") @ApiResponses({ @ApiResponse(code = 200, message = "ok", response = BasePageQueryDto.class) }) @Transactional AjaxResult withdrawalCash(@RequestBody @Validated WithdrawalCashDto withdrawalCashDto) { BizUser loginUser = redisUserLoginUtils.getLoginUser(BizUser.class); loginUser=bizUserDao.selectById(loginUser.getUserId()); if(withdrawalCashDto.getAmount()<1){ return AjaxResult.buildFailInstance("最小提现金额为1元"); }else if(withdrawalCashDto.getAmount()>20000){ return AjaxResult.buildFailInstance("最大提现金额为2万元"); }else{ if(loginUser.getWithdrawalCash()==null || loginUser.getWithdrawalCash()<withdrawalCashDto.getAmount()){ return AjaxResult.buildFailInstance("余额不足"); }else{ String txNo = codeService.get32LenNumberCode(); /*调试注释 weixinServiceUtil.comPay("提现", txNo,Integer.parseInt((withdrawalCashDto.getAmount()*1000)+""), loginUser.getOpenId(),loginUser.getCompanyId()); */ //记录收益流水 ShopRevenueFlow invitationRevenueFlow=new ShopRevenueFlow(); invitationRevenueFlow.setCompanyId(loginUser.getCompanyId()); invitationRevenueFlow.setCreateBy(MatrixConstance.SYSTEM_USER); invitationRevenueFlow.setUpdateBy(txNo); invitationRevenueFlow.setCreateTime(new Date()); invitationRevenueFlow.setUpdateTime(new Date()); invitationRevenueFlow.setAmount(-withdrawalCashDto.getAmount()); invitationRevenueFlow.setUserId(loginUser.getOpenId()); invitationRevenueFlow.setRevenueContent("提现"); shopRevenueFlowDao.insert(invitationRevenueFlow); //扣除用户剩余提现金额 loginUser.setWithdrawalCash(loginUser.getWithdrawalCash()-withdrawalCashDto.getAmount()); bizUserDao.updateByModel(loginUser); redisUserLoginUtils.updateUserInfo(loginUser); return AjaxResult.buildSuccessInstance("提现成功"); } } } } zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxSalesmanAction.java
@@ -159,7 +159,7 @@ BufferedImage qrcordImgBuf = ImageIO.read(new File(qrcodeSavePath)); //获取海报 BusParameterSettings posterSetting = busParameterSettingsDao.selectCompanyParamByCode(FenxiaoSettingConstant.FX_TG_POSTER, HostInterceptor.getCompanyId()); BusParameterSettings posterSetting = busParameterSettingsDao.selectCompanyParamByCode(FenxiaoSettingConstant.FX_TG_POSTER, loginUser.getCompanyId()); String posterPath=baseSavePath+"wxacode" + File.separatorChar+MD5Util.strToMD5(loginUser.getOpenId())+"poster.png"; ImageUtil.downloadPicture(posterSetting.getParamValue(),posterPath); BufferedImage posterImgBuf = ImageIO.read(new File(posterPath)); @@ -173,7 +173,6 @@ BufferedImage backgroundImgBuf = new BufferedImage(700, 900, BufferedImage.TYPE_4BYTE_ABGR); //绘制背景+产品 Graphics2D g = backgroundImgBuf.createGraphics(); //g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 1)); g.setColor(Color.WHITE); g.fillRect(0,0,700,900); g.drawImage(posterImgBuf,0,0,700, 700,null); zq-erp/src/main/java/com/matrix/system/shopXcx/api/dto/RevenueFlowDto.java
New file @@ -0,0 +1,26 @@ package com.matrix.system.shopXcx.api.dto; import com.matrix.core.pojo.BasePageQueryDto; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.NotNull; @Data @ApiModel(value = "RevenueFlowDto", description = "收益流水查询参数接收类") public class RevenueFlowDto extends BasePageQueryDto { @NotNull(message = "查询月份不能为空") @ApiModelProperty(value = "查询月份",example = "2021-03") private String queryTime; @ApiModelProperty(value = "收益类型 不传全部,1,收入,2支出", example = "1") private Integer revenueType; @ApiModelProperty(hidden = true) private String userId; } zq-erp/src/main/java/com/matrix/system/shopXcx/api/dto/WithdrawalCashDto.java
New file @@ -0,0 +1,20 @@ package com.matrix.system.shopXcx.api.dto; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.NotNull; @Data @ApiModel(value = "WithdrawalCashDto", description = "提现参数接收类") public class WithdrawalCashDto { @NotNull(message = "提现金额不能为空") @ApiModelProperty(value = "提现金额", example = "1") private Double amount; } zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/SalesOrderTask.java
@@ -7,6 +7,7 @@ import com.matrix.core.tools.LogUtil; import com.matrix.core.tools.StringUtils; import com.matrix.system.common.dao.BusParameterSettingsDao; import com.matrix.system.fenxiao.dao.ShopRevenueFlowDao; import com.matrix.system.fenxiao.dao.ShopSalesmanGradeDao; import com.matrix.system.fenxiao.dao.ShopSalesmanOrderDao; import com.matrix.system.fenxiao.entity.ShopSalesmanGrade; @@ -82,6 +83,7 @@ @Autowired private ShopSalesmanGradeDao shopSalesmanGradeDao; @Override @@ -176,6 +178,8 @@ invitationAmount=invitationAmount*zk; invitationOrder.setAmount(invitationAmount); shopSalesmanOrderDao.insert(invitationOrder); } } }else{ zq-erp/src/main/java/com/matrix/system/shopXcx/vo/SalesmanCenterInfo.java
@@ -27,8 +27,12 @@ @ApiModelProperty(value = "可提现金额") private String withdrawalCash; @ApiModelProperty(value = "邀请订单数") private String invitationOrderCount; @ApiModelProperty(value = "推广订单数") private String orderCount; private String salesorderCount; @ApiModelProperty(value = "客户数") zq-erp/src/main/resources/mybatis/mapper/fenxiao/ShopRevenueFlowDao.xml
@@ -32,4 +32,18 @@ <result property="companyId" column="company_id" /> </resultMap> <select id="selectRevenuFlowList" resultType="com.matrix.system.shopXcx.vo.SalesOrderVo"> select * from shop_revenue_flow where user_id=#{record.userId} and DATE_FORMAT(create_time,'%Y-%m')=#{record.queryTime} <if test="record.revenueType==1"> and amount>0 </if> <if test="record.revenueType==2"> <![CDATA[ and amount<0 ]]> </if> order by create_time desc </select> </mapper> zq-erp/src/main/resources/mybatis/mapper/fenxiao/ShopSalesmanApplyDao.xml
@@ -187,7 +187,10 @@ AND b.sales_user_id = #{openId} ) AS djsRevenue, ( SELECT count( * ) FROM shop_salesman_order c WHERE c.user_id = a.open_id AND c.sales_user_id = #{openId} ) AS orderCount, ( SELECT count( * ) FROM shop_salesman_order c WHERE c.user_id = a.open_id AND c.sales_user_id = #{openId} and revenue_type =1 ) AS salesorderCount, ( SELECT count( * ) FROM shop_salesman_order c WHERE c.user_id = a.open_id AND c.sales_user_id = #{openId} and revenue_type =2 ) AS invitationOrderCount, (select count(*) from biz_user where parent_open_id=#{openId} and is_sales=1) as invitationCount, (select count(*) from biz_user where parent_open_id=#{openId} and is_sales=2) as customerCount from biz_user a where