developrelease_toaliyun_real
| @@ -209,17 +209,8 @@ public class UploadController extends BaseController { | |||
| metadata.setContentType(multiReq.getContentType()); | |||
| metadata.setContentLength(multiReq.getSize()); | |||
| FileOutputStream fos = null; | |||
| BufferedInputStream fs = null; | |||
| String fileName = ""; | |||
| int dot = multiReq.getOriginalFilename().lastIndexOf('.'); | |||
| if (dot >= 0) { | |||
| fileName = "cimg/" + multiReq.getOriginalFilename().substring(dot, multiReq.getOriginalFilename().length()); | |||
| } else { | |||
| fileName = "cimg/" + UUID.randomUUID().toString(); | |||
| } | |||
| String fileName = multiReq.getOriginalFilename(); | |||
| fileName = "cimg/" + fileName; | |||
| ResultData data = awsUpload(multiReq, metadata, fileName); | |||
| return data; | |||
| } | |||
| @@ -17,7 +17,9 @@ public class HttpServletRequestWrapperFilter implements Filter { | |||
| ServletRequest requestWrapper = null; | |||
| if (request instanceof HttpServletRequest) { | |||
| String url = ((HttpServletRequest) request).getRequestURI(); | |||
| if (!url.contains("awsFileUpload") && !url.contains("ueditor/exec") | |||
| if (!url.contains("awsFileUpload") | |||
| && !url.contains("cimgUpload") | |||
| && !url.contains("ueditor/exec") | |||
| && !url.contains("/wxCUserBasicInfo/importTemplate")) { | |||
| requestWrapper = new BodyReaderHttpServletRequestWrapper((HttpServletRequest) request); | |||
| } else { | |||
| @@ -45,7 +45,9 @@ public class RequestInterceptor extends HandlerInterceptorAdapter { | |||
| String url = request.getRequestURL().toString(); | |||
| if(url.contains("pvlog") | |||
| || url.contains("awsFileUpload") | |||
| || url.contains("ueditor/exec")) { | |||
| || url.contains("cimgUpload") | |||
| || url.contains("ueditor/exec") | |||
| || url.contains("/wxCUserBasicInfo/importTemplate")) { | |||
| // pvlog不检查幂等 | |||
| // awsFileUpload不检查幂等 | |||
| // ueditor 不检查幂等 | |||
| @@ -6,6 +6,7 @@ import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.vo.WxCardSpendVo; | |||
| import com.iformall.enums.EnumMerchantStatus; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.*; | |||
| import io.swagger.annotations.Api; | |||
| @@ -106,10 +107,14 @@ public class WxCardPayController extends BaseController { | |||
| WxCUser user = getUser(); | |||
| WxMerchant merchant = wxMerchantService.getById(merchantId); | |||
| if (merchant.getStatus() == EnumMerchantStatus.NOT_VALID.getCode()) { | |||
| logger.error("商户已禁用, merchantId: " + merchant.getId()); | |||
| return new ResultData(ErrorCode.MERCHANT_INFO_NOT_VALID); | |||
| } | |||
| WxOrder order = null; | |||
| try { | |||
| order = wxOrderService.saveCardPayOrder(merchant, totalFeeStr, payment); | |||
| order = wxOrderService.saveCardPayOrder(merchant, user, totalFeeStr, payment); | |||
| } catch (MallinkException e) { | |||
| logger.error("saveCardPayOrder 1" + e.getMessage()); | |||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||
| @@ -1,9 +1,14 @@ | |||
| package com.iformall.schedule; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.config.PayProperty; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.enums.EnumAppType; | |||
| import com.iformall.enums.EnumCouponOrderStatus; | |||
| import com.iformall.enums.EnumCouponType; | |||
| import com.iformall.enums.EnumPayType; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.mapper.*; | |||
| import com.iformall.service.WxPayOrderService; | |||
| import com.iformall.service.WxRefundOrderService; | |||
| @@ -15,6 +20,7 @@ import org.springframework.stereotype.Component; | |||
| import org.springframework.transaction.annotation.Propagation; | |||
| import org.springframework.transaction.annotation.Transactional; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| @Component | |||
| @@ -50,20 +56,41 @@ public class CouponOrderExpiringSchedule { | |||
| List<WxCouponOrder> list = wxCouponOrderMapper.findExpiredCouponOrderByValidDate(); | |||
| list.parallelStream().forEach(co -> { | |||
| // 券过期与退款分离 | |||
| couponOrderExpire(co); | |||
| if(!co.getCouponType().equals(EnumCouponType.CARD_MULTIMCH.getCode())) { | |||
| // 非储值卡, 可以退款 | |||
| WxAppinfo appinfo = new WxAppinfo(); | |||
| appinfo.setTenantId(co.getTenantId()); | |||
| appinfo.setType(EnumAppType.B.getCode()); | |||
| appinfo = wxAppinfoMapper.findList(appinfo).get(0); | |||
| try { | |||
| wxRefundOrderService.createRefundOrder(payProperty.isReal(), appinfo, co.getId(), EnumPayType.PAY_AUTO_REFUND, null); | |||
| } catch (Exception e) { | |||
| logger.error("退款失败:"+e.getMessage()+"couponOrderId="+co.getId()); | |||
| } | |||
| } | |||
| for(WxCouponOrder co:list) { | |||
| WxAppinfo appinfo = new WxAppinfo(); | |||
| appinfo.setTenantId(co.getTenantId()); | |||
| appinfo.setType(EnumAppType.B.getCode()); | |||
| appinfo = wxAppinfoMapper.findList(appinfo).get(0); | |||
| }); | |||
| } | |||
| try { | |||
| wxRefundOrderService.createRefundOrder(payProperty.isReal(), appinfo, co.getId(), EnumPayType.PAY_AUTO_REFUND, null); | |||
| } catch (Exception e) { | |||
| logger.error("退款失败:"+e.getMessage()+"couponOrderId="+co.getId()); | |||
| continue; | |||
| } | |||
| private void couponOrderExpire(WxCouponOrder co) { | |||
| // 标记 couponOrder过期 | |||
| WxCouponOrder wxCouponOrder = new WxCouponOrder(); | |||
| wxCouponOrder.setId(co.getId()); | |||
| if(co.getCouponType().equals(EnumCouponType.CARD_MULTIMCH.getCode())) { | |||
| wxCouponOrder.setCouponOrderStatus(EnumCouponOrderStatus.CARD_OVER_TIME.getCode()); // 卡线下退款 | |||
| } else { | |||
| wxCouponOrder.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_OVER_TIME.getCode()); //券已过期 | |||
| } | |||
| wxCouponOrder.setUpdateDate(new Date()); | |||
| try { | |||
| wxCouponOrderMapper.updateByPrimaryKeySelective(wxCouponOrder); | |||
| } catch (Exception e) { | |||
| logger.error("db failed: couponOrder-" + wxCouponOrder.getId() + ", e:" + e.getMessage()); | |||
| } | |||
| } | |||
| } | |||
| @@ -37,21 +37,20 @@ public class OrderExpiringSchedule { | |||
| Map dateMap = new HashMap(); | |||
| Date curDate = new Date(); | |||
| Date expireDate = new Date(curDate.getTime() - TIME_OUT_VALUE ); | |||
| // 只检查券相关订单 | |||
| // 券相关订单 | |||
| dateMap.put("type", EnumOrderType.COUPON.getCode()); | |||
| dateMap.put("endDate", new Date(curDate.getTime() - TIME_OUT_VALUE )); | |||
| List<WxOrder> wxOrderList = wxOrderMapper.findListOfUnpaidOrderByDate(dateMap); | |||
| for(WxOrder wxOrder: wxOrderList){ | |||
| orderExpired(wxOrder); | |||
| } | |||
| dateMap.put("endDate", expireDate); | |||
| List<WxOrder> orderCoupons = wxOrderMapper.findListOfUnpaidOrderByDate(dateMap); | |||
| orderCoupons.parallelStream().forEach( o -> { | |||
| orderExpired(o); | |||
| }); | |||
| } | |||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||
| public void orderExpired(WxOrder order) { | |||
| order.setUpdateDate(new Date()); | |||
| order.setType(EnumOrderType.COUPON.getCode()); | |||
| order.setOrderStatus(EnumOrderStatus.ORDER_STATUS_OVERTIME_CANCEL.getCode()); | |||
| wxOrderMapper.updateByPrimaryKeySelective(order); | |||
| @@ -4,6 +4,7 @@ import cn.afterturn.easypoi.excel.annotation.Excel; | |||
| import javax.persistence.Transient; | |||
| import javax.validation.constraints.NotNull; | |||
| import javax.validation.constraints.Pattern; | |||
| import java.io.Serializable; | |||
| public class CUserBaseInfoT implements Serializable { | |||
| @@ -19,6 +20,7 @@ public class CUserBaseInfoT implements Serializable { | |||
| @Excel(name="手机号",width = 20,orderNum = "3") | |||
| @io.swagger.annotations.ApiModelProperty(value="微信用户绑定的手机号",name="phone") | |||
| @NotNull | |||
| @Pattern(regexp = "1[0123456789]\\d{9}", message = "手机号不正确") | |||
| private String phone; | |||
| /**用户昵称**/ | |||
| @Excel(name="微信昵称",width = 20,orderNum = "4") | |||
| @@ -51,10 +51,12 @@ public interface WxOrderService { | |||
| /** | |||
| * 商户码-储值卡支付 | |||
| * @param merchant | |||
| * @param cUser | |||
| * @param totalFeeStr | |||
| * @param payment | |||
| * @return 订单id | |||
| */ | |||
| WxOrder saveCardPayOrder(WxMerchant merchant, String totalFeeStr, Integer payment); | |||
| WxOrder saveCardPayOrder(WxMerchant merchant, WxCUser cUser, String totalFeeStr, Integer payment); | |||
| /** | |||
| * 免费券订单接口 | |||
| @@ -514,12 +514,13 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| ImportParams params = new ImportParams(); | |||
| IExcelDataHandler<CUserBaseInfoT> handler = new UserExcelHandler(); | |||
| handler.setNeedHandlerFields(new String[]{"姓名", "性别", "手机号", "微信昵称", "学历", "生日", "地址", "上次活跃时间", "注册时间", "标签", "成长值"});// 注意这里对应的是excel的列名。也就是对象上指定的列名。 | |||
| params.setDataHandler(handler); | |||
| //IExcelDataHandler<CUserBaseInfoT> handler = new UserExcelHandler(); | |||
| //handler.setNeedHandlerFields(new String[]{"姓名", "性别", "手机号", "微信昵称", "学历", "生日", "地址", "上次活跃时间", "注册时间", "标签", "成长值"});// 注意这里对应的是excel的列名。也就是对象上指定的列名。 | |||
| //params.setDataHandler(handler); | |||
| //params.setVerifyHandler(); | |||
| // 需要验证 | |||
| params.setNeedVerfiy(true); | |||
| params.setImportFields(new String[]{"姓名", "性别", "手机号", "微信昵称", "学历", "生日", "地址", "上次活跃时间", "注册时间", "标签", "成长值"}); | |||
| params.setNeedVerify(true); | |||
| try { | |||
| @@ -119,7 +119,7 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { | |||
| return new ResultData(ErrorCode.DB_FAIL.getCode(), "获取payAccount失败"); | |||
| } | |||
| // 5. 扣减计算 | |||
| // 4. 扣减计算 | |||
| Integer payment = cardInfo.getSaleAmount() * record.getDeductionAmount() / cardInfo.getAmount(); | |||
| Double dChargeFee = Math.ceil(payment * 1.0D * payAccount.getRate() / 10000); | |||
| Integer real_payment = payment - dChargeFee.intValue(); | |||
| @@ -132,7 +132,7 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { | |||
| remain_real_pament = cardInfo.getRemainingShareFeeAmount() - real_payment; | |||
| } | |||
| // 6 insert card_spend | |||
| // 5 insert card_spend | |||
| record.setId(idWorker.nextId()); | |||
| record.setPayment(payment); | |||
| record.setRealPayment(real_payment); | |||
| @@ -150,6 +150,19 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { | |||
| return new ResultData(ErrorCode.DB_FAIL.getCode(), "card spend 插入出错!"); | |||
| } | |||
| // 6. update order status | |||
| WxOrder orderUpdate = new WxOrder(); | |||
| orderUpdate.setId(order.getId()); | |||
| orderUpdate.setPaymentTime(curDate); | |||
| orderUpdate.setOrderStatus(EnumOrderStatus.ORDER_STATUS_PAYMENT_SUCCESS.getCode()); | |||
| orderUpdate.setUpdateDate(curDate); | |||
| try { | |||
| wxOrderMapper.updateByPrimaryKeySelective(orderUpdate); | |||
| } catch (Exception e) { | |||
| logger.error("order update error"); | |||
| return new ResultData(ErrorCode.DB_FAIL.getCode(), "order update 出错!"); | |||
| } | |||
| // 7. update card info | |||
| cardInfo.setRemainingAmount(remaingAmount); | |||
| cardInfo.setRemainingShareFeeAmount(remain_real_pament); | |||
| @@ -452,12 +452,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| @Override | |||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||
| public WxOrder saveCardPayOrder(WxMerchant merchant, String totalFeeStr, Integer payment) { | |||
| if (merchant.getStatus() == EnumMerchantStatus.NOT_VALID.getCode()) { | |||
| logger.error("商户已禁用, merchantId: " + merchant.getId()); | |||
| throw new MallinkException(ErrorCode.MERCHANT_INFO_NOT_VALID); | |||
| } | |||
| public WxOrder saveCardPayOrder(WxMerchant merchant, WxCUser cUser, String totalFeeStr, Integer payment) { | |||
| Date curr = new Date(); | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| @@ -473,6 +468,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| record.setOrderNumber(orderNumber); | |||
| record.setType(EnumOrderType.PREPAIDCARD.getCode()); | |||
| record.setProductId(merchant.getId()); | |||
| record.setcUserId(cUser.getId()); | |||
| record.setPaymentType(EnumPayType.PAY_PAYMENT.getCode()); | |||
| record.setPayment(payment); | |||
| record.setOrderStatus(EnumOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode()); | |||
| @@ -300,10 +300,6 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||
| throw new MallinkException(ErrorCode.REFUND_PAY_ORDER_IS_ZERO); | |||
| } | |||
| if (wxCouponOrder.getCouponOrderStatus().equals(EnumCouponOrderStatus.COUPON_ORDER_OVER_TIME.getCode())) { | |||
| logger.error("已过期: couponOrder-" + couponOrderId); | |||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_OVER_TIME); | |||
| } | |||
| if (wxCouponOrder.getCouponOrderStatus().equals(EnumCouponOrderStatus.COUPON_ORDER_INVALID.getCode())) { | |||
| logger.error("已退款: couponOrder-" + couponOrderId); | |||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_OVER_TIME); | |||
| @@ -91,11 +91,6 @@ | |||
| <include refid="dynamicWhereConditions" /> | |||
| </select> | |||
| <select id="findListByCouponIds" parameterType="com.iformall.domain.po.WxCouponChannel" resultMap="BaseResultMap"> | |||
| select <include refid="allColumns" /> from wx_coupon_channel cc | |||
| <include refid="dynamicWhereConditions" /> | |||
| </select> | |||
| <update id="updateStatusByCouponId" parameterType="com.iformall.domain.po.WxCouponChannel"> | |||
| update wx_coupon_channel set status=#{status} where tenant_id=#{tenantId} and coupon_id=#{couponId} | |||
| </update> | |||
| @@ -27,10 +27,14 @@ | |||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/> | |||
| <result column="business" jdbcType="INTEGER" property="business"/> | |||
| <result column="support_transfer" jdbcType="INTEGER" property="supportTransfer"/> | |||
| <result column="subsidy_type" jdbcType="INTEGER" property="subsidyType"/> | |||
| <result column="subsidy_num" jdbcType="INTEGER" property="subsidyNum"/> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`type`,`cover_img`,`title`,`sub_title`,`sale_price`,`use_price`,`use_limit_quantity`,`send_type`,`valid_type`,`valid_start_date`,`valid_end_date`,`valid_days`,`detail`,`price`,`unit`,`remain_inventory`,`inventory`,`remark`,`status`,`create_date`,`update_date`,`business`,`support_transfer`,`subsidy_num`,`subsidy_type` | |||
| `id`,`tenant_id`,`type`,`cover_img`,`title`,`sub_title`,`sale_price`,`use_price`,`use_limit_quantity`,`send_type`, | |||
| `valid_type`,`valid_start_date`,`valid_end_date`,`valid_days`,`detail`,`price`,`unit`,`remain_inventory`,`inventory`, | |||
| `remark`,`status`,`create_date`,`update_date`,`business`,`support_transfer`,`subsidy_num`,`subsidy_type` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| @@ -136,6 +140,14 @@ | |||
| and `support_transfer` = #{supportTransfer} | |||
| </if> | |||
| <if test=" null != subsidyType "> | |||
| and `subsidy_type` = #{subsidyType} | |||
| </if> | |||
| <if test=" null != subsidyNum "> | |||
| and `subsidy_num` = #{subsidyNum} | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| @@ -255,6 +267,14 @@ | |||
| and `support_transfer` = #{supportTransfer} | |||
| </if> | |||
| <if test=" null != subsidyType "> | |||
| and `subsidy_type` = #{subsidyType} | |||
| </if> | |||
| <if test=" null != subsidyNum "> | |||
| and `subsidy_num` = #{subsidyNum} | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| @@ -374,6 +394,14 @@ | |||
| and `support_transfer` = #{supportTransfer} | |||
| </if> | |||
| <if test=" null != subsidyType "> | |||
| and `subsidy_type` = #{subsidyType} | |||
| </if> | |||
| <if test=" null != subsidyNum "> | |||
| and `subsidy_num` = #{subsidyNum} | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| @@ -260,14 +260,7 @@ | |||
| <dependency> | |||
| <groupId>cn.afterturn</groupId> | |||
| <artifactId>easypoi-spring-boot-starter</artifactId> | |||
| <version>3.3.0</version> | |||
| </dependency> | |||
| <!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml-schemas --> | |||
| <dependency> | |||
| <groupId>org.apache.poi</groupId> | |||
| <artifactId>poi-ooxml-schemas</artifactId> | |||
| <version>3.15</version> | |||
| <version>4.0.0</version> | |||
| </dependency> | |||
| <!-- https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp --> | |||