TestController.php 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. <?php
  2. namespace App\Http\Controllers\Api;
  3. use App\Model\BoxDetail;
  4. use App\Model\Depart;
  5. use App\Model\InOutRecord;
  6. use App\Model\Inventory;
  7. use App\Model\OutBoundOrder;
  8. use App\Model\Product;
  9. use App\Model\ProductInventory;
  10. use App\Model\ProductPriceDetail;
  11. use App\Model\PurchaseOrderInfoForOutBound;
  12. use App\Model\ReturnExchangeOrder;
  13. use App\Service\Box\BoxHookService;
  14. use App\Service\CheckService;
  15. use App\Service\EmployeeService;
  16. use App\Service\MeasureService;
  17. use App\Service\OaService;
  18. use App\Service\OperationLogService;
  19. use App\Service\OrderNoService;
  20. use App\Service\SalesOrderService;
  21. use Illuminate\Http\Request;
  22. use Illuminate\Support\Facades\Hash;
  23. class TestController extends BaseController
  24. {
  25. public function tt(){
  26. }
  27. public function boxInsert(){
  28. }
  29. public function aa(){$this->test1();
  30. // $array = (new SalesOrderService())->salesOrderPdf(['id' => 26604],['id'=>1,'head'=>['id' =>2]]);
  31. // return view('pdf.salesOrder',['order' => $array]);
  32. $send_data[] = [
  33. 'employee_id' => 1,
  34. 'type' => 2,
  35. 'state' => 0,
  36. 'menu_id' => 34,
  37. 'order_number' => "T9RMO.202408071529012839",
  38. 'tmp_data' => [
  39. "T9RMO.202408071529012839",
  40. "施工单",
  41. '已完结',
  42. "ee",
  43. date('Y-m-d H:i:s'),
  44. ],
  45. ];
  46. (new OaService())->sendWxOaCheckMessage($send_data);dd(11)
  47. (new OaService())->sendWxMsg(1,2,0,34,["T9RMO.202408071529012839","施工单","待确认","陈庆鹏","2024-08-07 15:29:44"]);dd(1);
  48. // (new OaService())->sendWxMsg(1,3,2,48,["T9RMO.202408071529012839","拒绝","2024-08-07 15:29:44","(未填写原因)"],"/pages/ReturnExchangeOrder/detail/detail?order_number=55");
  49. //测试消息发送
  50. // $tmp_data = [
  51. // "T9XS.20240824095952611883",
  52. // '陈庆鹏(订单合同)',
  53. // '刁法森',
  54. // date('Y-m-d H:i:s'),
  55. // ];
  56. // (new OaService())->sendWxMsg(1,1,0,37,$tmp_data,"/pageA/pages/SalesOrder/detail/detail?order_number=T9XS.20240824095952611883");
  57. $tmp_data = [
  58. "XNCG202411241422297482",
  59. "拒绝",
  60. "2024-11-24 14:22:29",
  61. "测试"
  62. ];
  63. (new OaService())->sendWxMsg(1,3,2,44,$tmp_data,"/pageA/pages/SalesOrder/detail/detail?order_number=T9XX.2024080912410029251");dd(1);
  64. //测试消息发送
  65. $tmp_data = [
  66. "22222",
  67. '222',
  68. '审核通过',
  69. '22222',
  70. date('Y-m-d H:i:s'),
  71. ];
  72. // (new OaService())->sendWxMsg(1,2,1,37,$tmp_data,"/pages/SalesOrder/index/index");
  73. //测试消息发送
  74. $tmp_data = [
  75. "333333",
  76. '审核通过',
  77. date('Y-m-d H:i:s'),
  78. '22222',
  79. ];
  80. // (new OaService())->sendWxMsg(1,3,2,37,$tmp_data,"/pages/SalesOrder/index/index");
  81. die;
  82. $params = json_decode('{"api_key":"d3848b47-4179-4b02-8d32-b78cd7672c6c","return_url":"https://payment.rummyliver.in/notify/s2pay/payment","mode":"LIVE","order_id":"1710493215363410880003","amount":"501.00","currency":"INR","description":"for payment","name":"iahfi","email":"jvqbgvv2908699@outlook.com","phone":"9329086994","city":"Mumbai","zip_code":"400002","country":"IND"}',true);
  83. $hash_columns = ['merchant_reference_number','Amount','account_name','account_number','ifsc_code','bank_name','bank_branch','transfer_type','address_line_1', 'address_line_2', 'amount', 'api_key', 'city', 'country', 'currency', 'description', 'email', 'mode', 'name', 'order_id', 'phone', 'return_url', 'state', 'udf1', 'udf2', 'udf3', 'udf4', 'udf5', 'zip_code',];
  84. sort($hash_columns);
  85. $hash_data = '3b1db341fa70abc03af5c3676811a82bec99673f';
  86. foreach ($hash_columns as $column) {
  87. if (isset($params[$column])) {
  88. if (strlen($params[$column]) > 0) {
  89. $hash_data .= '|' . trim($params[$column]);
  90. }
  91. }
  92. }
  93. $hash = strtoupper(hash("sha512", $hash_data));
  94. var_dump($hash);die;
  95. return $hash;
  96. $text = '这是测试';
  97. $key = '72f8c912d462b1md034ff46cbedaskc80bf';
  98. $sign = Hash::make($text.$key);
  99. var_dump(Hash::check('这是测试'.'72f8c912d462b1md034ff46cbedaskc80bf',$sign));
  100. var_dump($sign);die;
  101. }
  102. public function test1(){dd(222);
  103. $service = new CheckService();
  104. $service->recordReturnExchangeOrder([],ReturnExchangeOrder::where('order_number',"TH202503071106328078")->first()->toArray());
  105. dd(1);
  106. $data = OutBoundOrder::where('del_time',0)->select('data_id')->get()->toArray();
  107. $data = array_column($data,'data_id');
  108. $data = ReturnExchangeOrder::where('del_time',0)
  109. ->whereIn('data_id',$data)
  110. ->where('type',ReturnExchangeOrder::Order_type)
  111. ->get()->toArray();
  112. dd($data);
  113. foreach ($data as $value){
  114. }
  115. dd(1);
  116. }
  117. public function clear(){
  118. $in_record = InOutRecord::select('top_depart_id')
  119. ->groupBy('top_depart_id')
  120. ->get()->toArray();
  121. $in_record = array_column($in_record,'top_depart_id');
  122. $depart = Depart::whereIn('id',$in_record)
  123. ->pluck('basic_type_id', 'id')
  124. ->toArray();
  125. $product_inventory = ProductInventory::whereIn('top_depart_id',$in_record)
  126. ->select('id','product_id','storehouse_id','number','lock_number','top_depart_id')
  127. ->get()->toArray();
  128. $product_inventory_map = [];
  129. foreach ($product_inventory as $value){
  130. $key = $value['top_depart_id'] . $value['product_id'];
  131. $product_inventory_map[$key] = 111;
  132. }
  133. $record_list = InOutRecord::where('del_time',0)
  134. ->whereIn('top_depart_id',$in_record)
  135. ->get()->toArray();
  136. $list = [];$error1 = [];
  137. foreach ($record_list as $value){
  138. $key = $value['top_depart_id'] . $value['product_id'];
  139. if(! isset($product_inventory_map[$key])){
  140. $error1[] = $value;
  141. }else{
  142. if(isset($list[$key])){
  143. $number = bcadd($value['number'],$list[$key],2);
  144. $list[$key] = $number;
  145. }else{
  146. $list[$key] = $value['number'];
  147. }
  148. }
  149. }
  150. if(! empty($error1)){
  151. foreach ($error1 as $value){
  152. InOutRecord::where('id', $value['id'])->update(['del_time' => 1233]);
  153. }dd(1);
  154. }
  155. $error = [];
  156. foreach ($product_inventory as $value){
  157. $key = $value['top_depart_id'] . $value['product_id'];
  158. if(isset($list[$key])){
  159. $tmp = $list[$key];
  160. if($tmp != $value['number']){
  161. $numbers = bcsub($value['number'],$tmp,2);
  162. $error[] = [
  163. 'product_id' => $value['product_id'],
  164. 'top_depart_id' => $value['top_depart_id'],
  165. 'depart_id' => $value['top_depart_id'],
  166. 'storehouse_id' => $value['storehouse_id'],
  167. 'number' => $numbers,
  168. ];
  169. }
  170. }else{
  171. $error[] = [
  172. 'product_id' => $value['product_id'],
  173. 'top_depart_id' => $value['top_depart_id'],
  174. 'depart_id' => $value['top_depart_id'],
  175. 'storehouse_id' => $value['storehouse_id'],
  176. 'number' => $value['number'],
  177. ];
  178. }
  179. }
  180. if(empty($error)) dd('no data');
  181. dd($error);
  182. $price_detail_map = [];
  183. $price_detail = ProductPriceDetail::whereIn('product_id',array_unique(array_column($error,'product_id')))
  184. ->select('product_id','price','basic_type_id')
  185. ->get()->toArray();
  186. foreach ($price_detail as $value){
  187. $price_detail_map[$value['product_id'] . $value['basic_type_id']] = $value['price'];
  188. }
  189. $price_2 = Product::whereIn('id',array_unique(array_column($error,'product_id')))
  190. ->pluck('retail_price','id')
  191. ->toArray();
  192. foreach ($error as $e => $value){
  193. $basic_type_id = $depart[$value['top_depart_id']] ?? 0;
  194. $key = $value['product_id'] . $basic_type_id;
  195. $price = $price_detail_map[$key] ?? 0;
  196. if(! $price) $price = $price_2[$value['product_id']] ?? 0;
  197. if(! $price) dd(1);
  198. if(! $value['number'] > 0) dd(2222);
  199. $error[$e]['price'] = $price;
  200. $error[$e]['crt_time'] = 1740758399;
  201. $error[$e]['order_type'] = PurchaseOrderInfoForOutBound::prefix2;
  202. $error[$e]['order_number'] = (new OrderNoService())->createOrderNumber(PurchaseOrderInfoForOutBound::prefix2);
  203. }
  204. InOutRecord::insert($error);
  205. dd(count($error),$error);
  206. }
  207. }