repairorder.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. //
  2. var mysql = require('mysql');
  3. var mysqlcn = require('./mysqlcn.js');
  4. var query = mysqlcn.query;
  5. var checkorder = require('./checkorder.js');
  6. var config = require('../pay/config.js');
  7. var doRepairOrder = function(){
  8. try{
  9. //console.log("------------doRepairOrder");
  10. // flag=1 的是没有发货的, o
  11. // talkingdata=1的是未向talkingdata 报道的订单
  12. query("select * from payinfo where flag=1 or talkingdata=1 and istest=2",function(qerr,vals,fields){
  13. if (vals!=null){
  14. for (var i=0;i<vals.length;++i){
  15. if (vals[i].flag==1){//玩家已支付补发钻石
  16. console.log("开始用户 %s 的订单 %s 自动补单!", vals[i].uid, vals[i].orderid);
  17. var uid = vals[i].uid;
  18. var orderid = vals[i].orderid;
  19. checkorder.pushproduct(query,vals[i].serverid,vals[i].orderid,function(ok){
  20. if (ok) {
  21. console.log("用户 %s 的订单 %s,补单成功!", uid, orderid);
  22. }
  23. else{
  24. console.log("用户 %s 的订单 %s,补单失败!", uid, orderid);
  25. }
  26. })
  27. }
  28. if (vals[i].talkingdata==1){//向tokingdata补发报告
  29. var option = config.reverse(vals[i].platform, vals[i].channel, vals[i].cfid);
  30. var TDappid = config.getAppID(vals[i].channel)
  31. console.log("向tokingdata补发报告TDappid=%s!", TDappid);
  32. checkorder.pushtalkingdata(
  33. query,
  34. TDappid,
  35. vals[i].platform,
  36. vals[i].uid,
  37. vals[i].orderid,
  38. option.price,
  39. option.typename,
  40. option.diamond,
  41. vals[i].submittime ? vals[i].submittime : vals[i].overtime,
  42. vals[i].payment_type,
  43. vals[i].serverid)
  44. }
  45. }
  46. }
  47. })
  48. }catch(err){
  49. console.log(err);
  50. }
  51. };
  52. setInterval(doRepairOrder, 30000);