he2802 3 yıl önce
ebeveyn
işleme
47de0e7279

+ 12 - 6
zhongzheng-api/src/main/java/com/zhongzheng/controller/cmmon/CommonController.java

@@ -32,6 +32,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.List;
 
 /**
@@ -76,12 +78,16 @@ public class CommonController extends BaseController {
 
     @ApiOperation("查询用户拥有的商品")
     @GetMapping("/test")
-    public AjaxResult<Integer> test(CourseQueryBo bo) throws InterruptedException {
-        Printer.num = 0;
-        new Thread(new Printer(0,redisCache)).start();
-        new Thread(new Printer(1,redisCache)).start();
-        new Thread(new Printer(2,redisCache)).start();
-        Thread.sleep(5000);
+    public AjaxResult<Integer> test(CourseQueryBo bo) throws InterruptedException, ParseException {
+        Long times = 1641312000L*1000;//时间戳
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
+        String dateString = formatter.format(times);
+        System.out.println(dateString);
+        String dateForma =null;
+        dateForma = dateString+" "+"13-06".replace("-", ":");
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+        Long time = sdf.parse(dateForma).getTime() / 1000;
+        System.out.println(time);
         return AjaxResult.success(Printer.num);
     }
 

BIN
zhongzheng-api/src/main/resources/config/apiclient_cert.p12


+ 20 - 4
zhongzheng-common/src/main/java/com/zhongzheng/common/config/WxSmallConfig.java

@@ -3,8 +3,10 @@ package com.zhongzheng.common.config;
 import com.zhongzheng.common.utils.wxpay.IWXPayDomain;
 import com.zhongzheng.common.utils.wxpay.WXPayConfig;
 import com.zhongzheng.common.utils.wxpay.WXPayConstants;
+import org.apache.commons.compress.utils.IOUtils;
 import org.springframework.beans.factory.annotation.Value;
 
+import java.io.ByteArrayInputStream;
 import java.io.InputStream;
 
 public class WxSmallConfig extends WXPayConfig {
@@ -15,6 +17,8 @@ public class WxSmallConfig extends WXPayConfig {
 
     private String key;
 
+    private byte[] certData;
+
     public WxSmallConfig(String appid,String mchid,String key)  {
       this.appid = appid;
       this.mchid = mchid;
@@ -35,10 +39,7 @@ public class WxSmallConfig extends WXPayConfig {
         return key;
     }
 
-    @Override
-    public InputStream getCertStream() {
-        return null;
-    }
+
 
     @Override
     public IWXPayDomain getWXPayDomain() {
@@ -57,4 +58,19 @@ public class WxSmallConfig extends WXPayConfig {
         return iwxPayDomain;
 
     }
+
+    //安全证书放在项目resources写法
+    @Override
+    public InputStream getCertStream() {
+        try {
+            InputStream certStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("config/apiclient_cert.p12");
+            this.certData = IOUtils.toByteArray(certStream);
+            certStream.close();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        ByteArrayInputStream certBis = new ByteArrayInputStream(this.certData);
+        return certBis;
+    }
+
 }

+ 1 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/IOrderGoodsRefundService.java

@@ -37,7 +37,7 @@ public interface IOrderGoodsRefundService extends IService<OrderGoodsRefund> {
 	 */
 	Boolean insertByAddBo(OrderGoodsRefundAddBo bo);
 
-	Map<String, String> placeRefundOrder(OrderGoodsRefundAddBo bo);
+	Map<String, String> placeRefundSmallOrder(OrderGoodsRefundAddBo bo);
 
 	/**
 	 * 根据编辑业务对象修改订单商品退款

+ 29 - 3
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/impl/OrderGoodsRefundServiceImpl.java

@@ -10,13 +10,16 @@ import com.zhongzheng.modules.goods.service.IGoodsService;
 import com.zhongzheng.modules.order.bo.OrderGoodsRefundAddBo;
 import com.zhongzheng.modules.order.bo.OrderGoodsRefundEditBo;
 import com.zhongzheng.modules.order.bo.OrderGoodsRefundQueryBo;
+import com.zhongzheng.modules.order.domain.Order;
 import com.zhongzheng.modules.order.domain.OrderGoods;
 import com.zhongzheng.modules.order.domain.OrderGoodsRefund;
 import com.zhongzheng.modules.order.mapper.OrderGoodsRefundMapper;
 import com.zhongzheng.modules.order.service.IOrderGoodsRefundService;
 import com.zhongzheng.modules.order.service.IOrderGoodsService;
+import com.zhongzheng.modules.order.service.IOrderService;
 import com.zhongzheng.modules.order.vo.OrderGoodsRefundVo;
 import com.zhongzheng.modules.user.domain.User;
+import com.zhongzheng.modules.wx.service.IWxPayService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -42,7 +45,11 @@ public class OrderGoodsRefundServiceImpl extends ServiceImpl<OrderGoodsRefundMap
     @Autowired
     private IOrderGoodsService iOrderGoodsService;
     @Autowired
+    private IOrderService iOrderService;
+    @Autowired
     private IGoodsService iGoodsService;
+    @Autowired
+    private IWxPayService iWxPayService;
 
     @Override
     public OrderGoodsRefundVo queryById(Long refundId){
@@ -93,7 +100,7 @@ public class OrderGoodsRefundServiceImpl extends ServiceImpl<OrderGoodsRefundMap
     }
 
     @Override
-    public Map<String, String> placeRefundOrder(OrderGoodsRefundAddBo bo) {
+    public Map<String, String> placeRefundSmallOrder(OrderGoodsRefundAddBo bo) {
         OrderGoods orderGoods = iOrderGoodsService.getOne(new LambdaQueryWrapper<OrderGoods>().eq(OrderGoods::getOrderSn,bo.getOrderSn())
                 .eq(OrderGoods::getGoodsId, bo.getGoodsId()));
         if(Validator.isEmpty(orderGoods)){
@@ -109,9 +116,28 @@ public class OrderGoodsRefundServiceImpl extends ServiceImpl<OrderGoodsRefundMap
             throw new CustomException("订单商品目前无法退款");
         }
         //订单商品
+        Order order = iOrderService.getOne(new LambdaQueryWrapper<Order>().eq(Order::getOrderSn,bo.getOrderSn()));
+        if(order.getStatus()==0){
+            throw new CustomException("订单无效");
+        }
+        if(order.getOrderFrom()!=2){
+            throw new CustomException("不支持非小程序订单退款");
+        }
+        //订单商品
         Goods goods = iGoodsService.getOne(new LambdaQueryWrapper<Goods>().eq(Goods::getGoodsId,bo.getGoodsId()));
-
-
+        if(goods.getGoodsType()==1){
+            //视频商品
+        }
+        OrderGoodsRefund add = BeanUtil.toBean(bo, OrderGoodsRefund.class);
+        validEntityBeforeSave(add);
+        add.setCreateTime(DateUtils.getNowTime());
+        add.setUpdateTime(DateUtils.getNowTime());
+        //退款单号
+        String out_trade_no = DateUtils.getDateOrderSn();
+        add.setRefundSn(out_trade_no);
+        add.setRefundFee(orderGoods.getGoodsReceived());
+        add.setUserId(order.getUserId());
+        Map<String, String> payResult =  iWxPayService.refund(out_trade_no,order.getTransid(),order.getPayPrice().toString(),"1");
         return null;
     }
 

+ 1 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/schedule/service/impl/ScheduleServiceImpl.java

@@ -757,7 +757,7 @@ public class ScheduleServiceImpl extends ServiceImpl<PolyvVideoMapper, PolyvVide
         List<UserSubscribeVo> userSubscribeVos = iUserSubscribeService.listSubscribe(userSubscribeQueryBo);
         for (UserSubscribeVo userSubscribeVo : userSubscribeVos) {
             Date date = new Date();
-            Long times = userSubscribeVo.getApplySiteExamTime();//时间戳
+            Long times = userSubscribeVo.getApplySiteExamTime()*1000;//时间戳
             SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
             String dateString = formatter.format(times);
             String dateForma =null;

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/wx/service/IWxPayService.java

@@ -33,4 +33,6 @@ public interface IWxPayService {
 
 	boolean joinLockGrade(String orderSn,Long goodsId,Long orderGoodsId);
 
+	Map<String, String> refund(String out_refund_no,String transaction_id,  String refund_fee, String total_fee);
+
 }

+ 30 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/wx/service/impl/WxPayServiceImpl.java

@@ -417,4 +417,34 @@ public class WxPayServiceImpl  implements IWxPayService {
         return true;
     }
 
+    @Override
+    public Map<String, String> refund(String out_refund_no,String transaction_id, String refund_fee, String total_fee) {
+        WxSmallConfig config = new WxSmallConfig(appid,mchid,key);
+        try {
+            WXPay wxpay = new WXPay(config);
+            Map<String, String> data = new HashMap<String, String>();
+            data.put("out_refund_no", out_refund_no);
+            data.put("transaction_id", transaction_id);
+            data.put("device_info", "");
+            data.put("fee_type", "CNY");
+            data.put("refund_fee", "1");
+            data.put("total_fee", "1");
+    //        Map<String, String> resp = wxpay.unifiedOrder(data);
+
+            Map<String, String> result = new HashMap<>();
+            //         result.put("provider","wxpay");
+            result.put("appId",appid);
+            result.put("nonceStr",WXPayUtil.generateNonceStr());
+            result.put("signType","MD5");
+            result.put("sign", WXPayUtil.generateSignature(result, key, WXPayConstants.SignType.MD5));
+            Map rMap = wxpay.refund(data);
+            System.out.println(rMap);
+            return rMap;
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return null;
+    }
+
 }