TaskSubscribe.php 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. <?php
  2. namespace crmeb\subscribes;
  3. use app\admin\model\system\SystemAttachment;
  4. use app\models\lala\LalaPinkJoin;
  5. use app\models\mining\UserMiningMachine;
  6. use app\models\point_plan\UserPointPlan;
  7. use app\models\store\StoreBargainUser;
  8. use app\models\store\StoreOrder;
  9. use app\models\store\StorePink;
  10. use app\models\user\UserRecharge;
  11. use app\models\user\UserToken;
  12. use crmeb\basic\BaseModel;
  13. use crmeb\services\blockchain\BlockChianService;
  14. use think\facade\Db;
  15. use think\facade\Log;
  16. /**
  17. * 定时任务类
  18. * Class TaskSubscribe
  19. * @package crmeb\subscribes
  20. */
  21. class TaskSubscribe
  22. {
  23. public function handle()
  24. {
  25. }
  26. /**
  27. * 2秒钟执行的方法
  28. */
  29. public function onTask_2()
  30. {
  31. }
  32. /**
  33. * 6秒钟执行的方法
  34. */
  35. public function onTask_6()
  36. {
  37. }
  38. /**
  39. * 10秒钟执行的方法
  40. */
  41. public function onTask_10()
  42. {
  43. }
  44. /**
  45. * 30秒钟执行的方法
  46. */
  47. public function onTask_30()
  48. {
  49. try {
  50. $start_time = time();
  51. $res = LalaPinkJoin::openAward();
  52. $end_time = time();
  53. @file_put_contents('openAwardTime.txt', '【' . date('Y-m-d H:i:s') . '】' . ($start_time - $end_time) . '秒' . PHP_EOL, FILE_APPEND);
  54. if (!$res) {
  55. @file_put_contents('openAward.txt', '【' . date('Y-m-d H:i:s') . '】' . BaseModel::getErrorInfo() . PHP_EOL, FILE_APPEND);
  56. }
  57. } catch (\Exception $e) {
  58. Log::error('openAward:' . $e->getMessage());
  59. }
  60. try {
  61. $start_time = time();
  62. LalaPinkJoin::autoPink();//自动拼团
  63. $end_time = time();
  64. @file_put_contents('autoPinkTime.txt', '【' . date('Y-m-d H:i:s') . '】' . ($start_time - $end_time) . '秒' . PHP_EOL, FILE_APPEND);
  65. } catch (\Exception $e) {
  66. Log::error('autoPink:' . $e->getMessage());
  67. }
  68. try {
  69. Db::startTrans();
  70. StoreBargainUser::startBargainUserStatus();//批量修改砍价状态为 砍价失败
  71. Db::commit();
  72. } catch (\Exception $e) {
  73. Db::rollback();
  74. }
  75. try {
  76. Db::startTrans();
  77. StoreOrder::orderUnpaidCancel();//订单未支付默认取消
  78. Db::commit();
  79. } catch (\Exception $e) {
  80. Db::rollback();
  81. }
  82. try {
  83. Db::startTrans();
  84. StoreOrder::startTakeOrder();//7天自动收货
  85. Db::commit();
  86. } catch (\Exception $e) {
  87. Db::rollback();
  88. }
  89. try {
  90. Db::startTrans();
  91. StorePink::statusPink();//拼团到期修改状态
  92. Db::commit();
  93. } catch (\Exception $e) {
  94. Db::rollback();
  95. }
  96. }
  97. /**
  98. * 60秒钟执行的方法
  99. */
  100. public function onTask_60()
  101. {
  102. try {
  103. $start_time = time();
  104. LalaPinkJoin::sendMoney();//自动拼团
  105. $end_time = time();
  106. @file_put_contents('sendMoneyTime.txt', '【' . date('Y-m-d H:i:s') . '】' . ($start_time - $end_time) . '秒' . PHP_EOL, FILE_APPEND);
  107. } catch (\Exception $e) {
  108. Log::error('sendMoney:' . $e->getMessage());
  109. }
  110. try {
  111. $start_time = time();
  112. $res = UserMiningMachine::dayMining();//每日挖矿
  113. $end_time = time();
  114. @file_put_contents('dayMiningTime.txt', '【' . date('Y-m-d H:i:s') . '】' . ($start_time - $end_time) . '秒' . PHP_EOL, FILE_APPEND);
  115. if (!$res) {
  116. @file_put_contents('mining.txt', '【' . date('Y-m-d H:i:s') . '】' . UserMiningMachine::getErrorInfo() . PHP_EOL, FILE_APPEND);
  117. }
  118. } catch (\Exception $e) {
  119. @file_put_contents('mining.txt', '【' . date('Y-m-d H:i:s') . '】' . $e->getMessage() . PHP_EOL, FILE_APPEND);
  120. }
  121. try {
  122. $start_time = time();
  123. UserPointPlan::day_release();//每日释放
  124. $end_time = time();
  125. @file_put_contents('dayReleaseTime.txt', '【' . date('Y-m-d H:i:s') . '】' . ($start_time - $end_time) . '秒' . PHP_EOL, FILE_APPEND);
  126. } catch (\Exception $e) {
  127. Log::error('day_release:' . $e->getMessage());
  128. }
  129. try {
  130. $start_time = time();
  131. UserPointPlan::day_release_ticket();//每日释放
  132. $end_time = time();
  133. @file_put_contents('dayReleaseTicketTime.txt', '【' . date('Y-m-d H:i:s') . '】' . ($start_time - $end_time) . '秒' . PHP_EOL, FILE_APPEND);
  134. } catch (\Exception $e) {
  135. Log::error('day_release_ticket:' . $e->getMessage());
  136. }
  137. }
  138. /**
  139. * 180秒钟执行的方法
  140. */
  141. public function onTask_180()
  142. {
  143. }
  144. /**
  145. * 300秒钟执行的方法
  146. */
  147. public function onTask_300()
  148. {
  149. try {
  150. UserToken::startTrans();
  151. $start_time = time();
  152. UserToken::delToken();
  153. $end_time = time();
  154. @file_put_contents('delTokenTime.txt', '【' . date('Y-m-d H:i:s') . '】' . ($start_time - $end_time) . '秒' . PHP_EOL, FILE_APPEND);
  155. UserToken::commit();
  156. } catch (\Exception $e) {
  157. Log::error('delToken:' . $e->getMessage());
  158. UserToken::rollback();
  159. }
  160. try {
  161. BaseModel::beginTrans();
  162. $start_time = time();
  163. $res = StoreOrder::sendProductReturn();
  164. $end_time = time();
  165. @file_put_contents('sendProductReturn.txt', '【' . date('Y-m-d H:i:s') . '】' . ($start_time - $end_time) . '秒' . PHP_EOL, FILE_APPEND);
  166. BaseModel::checkTrans($res);
  167. if (!$res) {
  168. Log::error('sendProductReturn:' . StoreOrder::getErrorInfo());
  169. }
  170. } catch (\Exception $e) {
  171. Log::error('sendProductReturn:' . $e->getMessage());
  172. BaseModel::rollbackTrans();
  173. }
  174. try {
  175. BaseModel::beginTrans();
  176. $start_time = time();
  177. $res = UserRecharge::sendReturn();
  178. $end_time = time();
  179. @file_put_contents('sendRechargeReturn.txt', '【' . date('Y-m-d H:i:s') . '】' . ($start_time - $end_time) . '秒' . PHP_EOL, FILE_APPEND);
  180. BaseModel::checkTrans($res);
  181. if (!$res) {
  182. Log::error('sendRechargeReturn:' . UserRecharge::getErrorInfo());
  183. }
  184. } catch (\Exception $e) {
  185. Log::error('sendRechargeReturn:' . $e->getMessage());
  186. BaseModel::rollbackTrans();
  187. }
  188. try {
  189. BaseModel::beginTrans();
  190. $start_time = time();
  191. $res = StoreOrder::returnAreaPrice();
  192. $end_time = time();
  193. @file_put_contents('returnAreaPrice.txt', '【' . date('Y-m-d H:i:s') . '】' . ($start_time - $end_time) . '秒' . PHP_EOL, FILE_APPEND);
  194. BaseModel::checkTrans($res);
  195. if (!$res) {
  196. Log::error('returnAreaPrice:' . StoreOrder::getErrorInfo());
  197. }
  198. } catch (\Exception $e) {
  199. Log::error('returnAreaPrice:' . $e->getMessage());
  200. BaseModel::rollbackTrans();
  201. }
  202. try {
  203. BaseModel::beginTrans();
  204. $start_time = time();
  205. $res = StoreOrder::returnPartnerPrice();
  206. $end_time = time();
  207. @file_put_contents('returnPartnerPrice.txt', '【' . date('Y-m-d H:i:s') . '】' . ($start_time - $end_time) . '秒' . PHP_EOL, FILE_APPEND);
  208. BaseModel::checkTrans($res);
  209. if (!$res) {
  210. Log::error('returnPartnerPrice:' . StoreOrder::getErrorInfo());
  211. }
  212. } catch (\Exception $e) {
  213. Log::error('returnPartnerPrice:' . $e->getMessage());
  214. BaseModel::rollbackTrans();
  215. }
  216. SystemAttachment::emptyYesterdayAttachment();//清除昨日海报
  217. StoreOrder::sendTen();//10分钟未付款发送通知
  218. // $start_time = time();
  219. // BlockChianService::autoGetTransfer();
  220. // $end_time = time();
  221. // @file_put_contents('autoGetTransferTime.txt', '【' . date('Y-m-d H:i:s') . '】' . ($start_time - $end_time) . '秒' . PHP_EOL, FILE_APPEND);
  222. // $start_time = time();
  223. // BlockChianService::autoCheckTransfer();
  224. // $end_time = time();
  225. // @file_put_contents('autoCheckTransferTime.txt', '【' . date('Y-m-d H:i:s') . '】' . ($start_time - $end_time) . '秒' . PHP_EOL, FILE_APPEND);
  226. }
  227. /**
  228. * 300秒钟执行的方法
  229. */
  230. public function onTask_7200()
  231. {
  232. }
  233. }