eganwu 1 vuosi sitten
vanhempi
commit
0fd3d5e76f

+ 4 - 3
src/custom/restcontroller/system/payment/wechatpay.java

@@ -172,7 +172,7 @@ public class wechatpay extends Controller {
             order_amount = new Double(sys_payorderRows.get(0).getDouble("amount") * 100).intValue();
         }
 
-        String response = wechatMiniProgram.createPayOrder(orderno, trade_type, wechat_code, "", "使用年费",order_amount);
+        String response = wechatMiniProgram.createPayOrder("wechatsaletool",orderno, trade_type, wechat_code, "", "使用年费",order_amount);
         JSONObject jsonObject = JSONObject.parseObject(response);
         if (jsonObject.containsKey("prepay_id")) {
             String package_str = "prepay_id=" + jsonObject.getStringValue("prepay_id");
@@ -209,6 +209,7 @@ public class wechatpay extends Controller {
 
     @API(title = "小程序门店支付", apiversion = R.ID20240507102402.v1.class)
     public String createStoreWechatOrder() throws Exception {
+        String systemclient="marketingtool";
         String sonum = content.getString("sonum");
         String wechat_code = content.getString("wechat_code");
         //APP、JSAPI
@@ -220,8 +221,8 @@ public class wechatpay extends Controller {
             order_amount = new Double(custorderRows.get(0).getDouble("amount") * 100).intValue();
         }
 
-        WechatMiniProgram wechatMiniProgram = new WechatMiniProgram("wechatsaletool");
-        String response = wechatMiniProgram.createPayOrder(sonum, trade_type, wechat_code, "", "购买商品",order_amount);
+        WechatMiniProgram wechatMiniProgram = new WechatMiniProgram(systemclient);
+        String response = wechatMiniProgram.createPayOrder(systemclient,sonum, trade_type, wechat_code, "", "购买商品",order_amount);
         JSONObject jsonObject = JSONObject.parseObject(response);
         if (jsonObject.containsKey("prepay_id")) {
             String package_str = "prepay_id=" + jsonObject.getStringValue("prepay_id");

+ 1 - 1
src/custom/restcontroller/webmanage/saletool/sharematerial/LongPicText.java

@@ -203,7 +203,7 @@ public class LongPicText extends Controller {
         Long sat_sharematerialid = content.getLongValue("sat_sharematerialid");
 
         QuerySQL querySQ = SQLFactory.createQuerySQL(this, "sat_sharematerial"
-                        ,"sat_sharematerialid","sharepagecontrol","type","title","siteid")
+                        ,"sat_sharematerialid","sharepagecontrol","type","title","siteid","content")
                 .setTableAlias("t1");
         querySQ.setWhere("sat_sharematerialid", sat_sharematerialid);
         Rows rows = querySQ.query();

+ 18 - 0
src/custom/service/WechatService.java

@@ -14,8 +14,11 @@ public class WechatService extends ServiceController {
     @Override
     public void serviceRun() throws YosException {
         try {
+            //账号付费信息
             dbConnect.runSqlUpdate("UPDATE sys_payorder SET ispaid=3 WHERE createdate < CURRENT_DATE and ispaid=0");
             queryPayorder_N();
+            //付费订单
+            queryCustOrder();
         } catch (IOException e) {
             e.printStackTrace();
         }
@@ -42,6 +45,21 @@ public class WechatService extends ServiceController {
         }
     }
 
+    public void queryCustOrder() throws YosException, IOException {
+        String sql = "SELECT sonum,siteid from sa_custorder WHERE paymode='微信支付' and ispaid=1 and deleted = 0 ";
+        Rows rows = dbConnect.runSqlQuery(sql);
+        for (Row row : rows) {
+            String orderno = row.getString("sonum");
+            String siteid = row.getString("siteid");
+            WeChatHelper weChatHelper = new WeChatHelper();
+            JSONObject object = weChatHelper.queryOrder(orderno + "J");
+
+            if (object != null) {
+                weChatHelper.updateCustOrder(object, siteid);
+            }
+        }
+    }
+
 
     /**
      * 订单查询

+ 26 - 0
src/custom/utility/wechat/WeChatHelper.java

@@ -127,6 +127,32 @@ public class WeChatHelper extends BaseClass {
         return true;
     }
 
+    public boolean updateCustOrder(JSONObject wechatOrder, String siteid) throws YosException {
+        String trade_state = wechatOrder.getString("trade_state");
+        String out_trade_no = wechatOrder.getString("out_trade_no");
+        out_trade_no = out_trade_no.substring(0, out_trade_no.length() - 1);
+        Rows custorderRows = dbConnect.runSqlQuery("select * from sa_custorder where sonum='" + out_trade_no + "' and siteid='" + siteid + "'");
+        for (Row custorderRow : custorderRows) {
+            ArrayList<String> sqllist = new ArrayList<>();
+            Long userid = custorderRow.getLong("createuserid");
+            String paymode = custorderRow.getString("paymode");
+            sqllist.add("update sa_custorder set wechatpayorder='" + wechatOrder + "' where sonum='" + out_trade_no + "' and siteid='" + siteid + "'");
+            if ("SUCCESS".equalsIgnoreCase(trade_state)) {
+                System.err.println(wechatOrder);
+                String paytime = DateString2formatString(wechatOrder.getString("success_time"));
+                sqllist.add("update sa_custorder set ispaid=2,paytime='" + paytime + "',status='已付款' where sonum='" + out_trade_no + "' and siteid='" + siteid + "'");
+                Remind remind = new Remind(siteid);
+                remind.setTouserid(userid);
+                remind.setType("pay");
+                remind.setTitle(paymode + "成功");
+                remind.setContent("success");
+                remind.sendByDialogMsg();
+            }
+            dbConnect.runSqlUpdate(sqllist);
+        }
+        return true;
+    }
+
     public Long getusersiteid(Long userid, String siteid) throws YosException {
         Rows rows = dbConnect.runSqlQuery("SELECT usersiteid from sys_usersite WHERE userid='" + userid + "' and siteid='" + siteid + "'");
         return rows.get(0).getLong("usersiteid");

+ 2 - 2
src/custom/utility/wechat/miniprogram/WechatMiniProgram.java

@@ -110,8 +110,8 @@ public class WechatMiniProgram extends BaseClass {
      * @param custip      客户端IP地址
      * @return
      */
-    public String createPayOrder(String orderno, String trade_type, String wechat_code, String custip,  String title,int order_amount) throws YosException {
-        WechatPay wechatPay = new WechatPay("wechatsaletool");
+    public String createPayOrder(String systemclient,String orderno, String trade_type, String wechat_code, String custip,  String title,int order_amount) throws YosException {
+        WechatPay wechatPay = new WechatPay(systemclient);
         return wechatPay.createPayOrder(orderno, trade_type, getWechatUserID(wechat_code).getOpenid(), custip, title, order_amount);
     }
 

+ 7 - 7
src/custom/utility/wechat/wechatpay/WechatPay.java

@@ -66,13 +66,13 @@ public class WechatPay extends BaseClass {
      * @param out_trade_no 商户订单号
      * @return
      */
-    public void queryOrder(String out_trade_no) throws YosException {
-        QueryOrderRequest queryOrderRequest = new QueryOrderRequest();
-        queryOrderRequest.setAppid(WeChatHelper.appid);
-        queryOrderRequest.setMch_id(WeChatHelper.mch_id);
-        queryOrderRequest.setOut_trade_no(out_trade_no);
-        updatePayOrder(queryOrderRequest.getOrder(WeChatHelper.mch_key));
-    }
+//    public void queryOrder(String out_trade_no) throws YosException {
+//        QueryOrderRequest queryOrderRequest = new QueryOrderRequest();
+//        queryOrderRequest.setAppid(WeChatHelper.appid);
+//        queryOrderRequest.setMch_id(WeChatHelper.mch_id);
+//        queryOrderRequest.setOut_trade_no(out_trade_no);
+//        updatePayOrder(queryOrderRequest.getOrder(WeChatHelper.mch_key));
+//    }
 
     /**
      * 订单关闭