UserTax.php 558 B

12345678910111213141516171819202122232425
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. class UserTax extends Model
  5. {
  6. protected $type=[
  7. 'tax'=>'json',
  8. ];
  9. public static function fromOrder(Orders $orders){
  10. if($orders['tax']){
  11. $has=self::where('user_id',$orders['user_id'])->where('tax',json_encode($orders['tax'],JSON_UNESCAPED_UNICODE))->find();
  12. if(!$has) {
  13. self::create([
  14. 'user_id' => $orders['user_id'],
  15. 'tax' => $orders['tax'],
  16. ]);
  17. }
  18. }
  19. }
  20. }