CharCashItem_OutputBox.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace App\Models\Char;
  3. use Illuminate\Database\Eloquent\Factories\HasFactory;
  4. use Illuminate\Database\Eloquent\Model;
  5. use App\Models\Char\CharBase;
  6. class CharCashItem_OutputBox extends Model
  7. {
  8. protected $connection = "Char";
  9. protected $table = "Table_CharCashItem_OutputBox";
  10. protected $primaryKey = "ItemDBIndex";
  11. protected $dates = ["CreateDate", "DeleteDate"];
  12. protected $fillable =
  13. [
  14. "ItemDBIndex", "Owner", "Kind", "RecId", "Amount", "strChargeNo", "Deleted", "CreateDate", "DeleteDate",
  15. "GaveCharName", "Confirm", "Period", "Price", "evPType", "Comment"
  16. ];
  17. public $timestamps = false;
  18. public static function SENDITEMOUTPUTBOX($request)
  19. {
  20. if($request['Owner'] == ""){
  21. $chars = CharBase::get();
  22. foreach ($chars as $char) {
  23. if($char->Online == 1){
  24. $send = new CharCashItem_OutputBox();
  25. $send->Owner = $char->DBKey;
  26. $send->Kind = $request['Kind'];
  27. $send->RecId = trim(strtolower($request['RecId']));
  28. $send->Amount = $request['Amount'];
  29. $send->strChargeNo = "*";
  30. $send->Deleted = 0;
  31. $send->CreateDate = now();
  32. $send->DeleteDate = now();
  33. $send->GaveCharName = "*";
  34. $send->Confirm = 0;
  35. $send->Period = $request['Period'];
  36. $send->Price = 0;
  37. $send->evPType = $request['evPType'];
  38. $send->Comment = $request['Comment'];
  39. $send->save();
  40. }
  41. }
  42. }else{
  43. $send = new CharCashItem_OutputBox();
  44. $send->Owner = $request['Owner'];
  45. $send->Kind = $request['Kind'];
  46. $send->RecId = trim(strtolower($request['RecId']));
  47. $send->Amount = $request['Amount'];
  48. $send->strChargeNo = "*";
  49. $send->Deleted = 0;
  50. $send->CreateDate = now();
  51. $send->DeleteDate = now();
  52. $send->GaveCharName = "*";
  53. $send->Confirm = 0;
  54. $send->Period = $request['Period'];
  55. $send->Price = 0;
  56. $send->evPType = $request['evPType'];
  57. $send->Comment = $request['Comment'];
  58. $send->save();
  59. }
  60. }
  61. }